Skip to content

Commit

Permalink
Merge pull request #97 from id/fix-time-to-first-response
Browse files Browse the repository at this point in the history
fix: fix time to first response
  • Loading branch information
zkoppert authored Aug 7, 2023
2 parents c3d29d0 + 3d63f98 commit f5bda66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test_time_to_first_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ def test_measure_time_to_first_response(self):
"""
# Set up the mock GitHub issues
mock_issue1 = MagicMock()
mock_issue1.comments = 1
mock_issue1.comments = 2
mock_issue1.created_at = "2023-01-01T00:00:00Z"

mock_comment1 = MagicMock()
mock_comment1.created_at = datetime.fromisoformat("2023-01-02T00:00:00Z")
mock_issue1.issue.comments.return_value = [mock_comment1]
mock_comment2 = MagicMock()
mock_comment2.created_at = datetime.fromisoformat("2023-01-02T12:00:00Z")
mock_issue1.issue.comments.return_value = [mock_comment1, mock_comment2]

# Call the function
result = measure_time_to_first_response(mock_issue1, None)
Expand Down Expand Up @@ -105,7 +107,9 @@ def test_measure_time_to_first_response_only_ignored_users(self):
mock_issue1.issue.comments.return_value = [mock_comment1, mock_comment2]

# Call the function
result = measure_time_to_first_response(mock_issue1, None, ["ignored_user", "ignored_user2"])
result = measure_time_to_first_response(
mock_issue1, None, ["ignored_user", "ignored_user2"]
)
expected_result = None

# Check the results
Expand Down
2 changes: 2 additions & 0 deletions time_to_first_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def measure_time_to_first_response(
if comment.user.login in ignore_users:
continue
first_comment_time = comment.created_at
break

# Check if the issue is actually a pull request
# so we may also get the first review comment time
Expand All @@ -66,6 +67,7 @@ def measure_time_to_first_response(
if review_comment.user.login in ignore_users:
continue
first_review_comment_time = review_comment.submitted_at
break

# Figure out the earliest response timestamp
if first_comment_time and first_review_comment_time:
Expand Down

0 comments on commit f5bda66

Please sign in to comment.