Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix time to first response #97

Merged
merged 2 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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