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

#338: fix review times in QoS #342

Merged
merged 1 commit into from
Sep 18, 2024
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
4 changes: 2 additions & 2 deletions judges/quality-of-service/quality-of-service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
"repo:#{repo} type:pr is:merged closed:>#{f.since.utc.iso8601[0..9]}"
)[:items].each do |pr|
pr_reviews = Fbe.octo.pull_request_reviews(repo, pr[:number])
pr_review = pr_reviews.min_by { |r| r[:submitted_at] }
review_times << (pr[:merged_at] - pr_review[:submitted_at]).to_i if pr_review
pr_review = pr_reviews.select { |r| r[:submitted_at] }.min_by { |r| r[:submitted_at] }
review_times << (pr[:pull_request][:merged_at] - pr_review[:submitted_at]).to_i if pr_review
review_comments << Fbe.octo.review_comments(repo, pr[:number]).size
reviewers << pr_reviews.map { |r| r.dig(:user, :id) }.uniq.size
reviews << pr_reviews.size
Expand Down
63 changes: 47 additions & 16 deletions test/judges/test-quality-of-service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def test_runs_when_run_duration_ms_is_nil
'q=repo:foo/foo%20type:pr%20is:merged%20closed:%3E2024-07-15',
body: {
total_count: 1, incomplete_results: false, items: [
{ id: 50, number: 12, title: 'Awesome 12', merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
{
id: 50, number: 12, title: 'Awesome 12',
pull_request: { merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
}
]
}
)
Expand Down Expand Up @@ -600,11 +603,26 @@ def test_quality_of_service_average_hocs_and_files
body: {
total_count: 1, incomplete_results: false,
items: [
{ id: 50, number: 12, title: 'Awesome 12', merged_at: Time.parse('2024-08-23 18:30:00 UTC') },
{ id: 52, number: 14, title: 'Awesome 14', merged_at: Time.parse('2024-08-23 18:30:00 UTC') },
{ id: 54, number: 16, title: 'Awesome 16', merged_at: Time.parse('2024-08-23 18:30:00 UTC') },
{ id: 56, number: 18, title: 'Awesome 18', merged_at: Time.parse('2024-08-23 18:30:00 UTC') },
{ id: 58, number: 20, title: 'Awesome 20', merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
{
id: 50, number: 12, title: 'Awesome 12',
pull_request: { merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
},
{
id: 52, number: 14, title: 'Awesome 14',
pull_request: { merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
},
{
id: 54, number: 16, title: 'Awesome 16',
pull_request: { merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
},
{
id: 56, number: 18, title: 'Awesome 18',
pull_request: { merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
},
{
id: 58, number: 20, title: 'Awesome 20',
pull_request: { merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
}
]
}
)
Expand Down Expand Up @@ -739,12 +757,21 @@ def test_quality_of_service_average_review_time_comments_reviewers_and_reviews
body: {
total_count: 1, incomplete_results: false,
items: [
{ id: 50, number: 12, title: 'Awesome 12', created_at: Time.parse('2024-08-20 22:00:00 UTC'),
merged_at: Time.parse('2024-08-27 18:30:00 UTC') },
{ id: 51, number: 14, title: 'Awesome 14', created_at: Time.parse('2024-08-23 12:00:00 UTC'),
merged_at: Time.parse('2024-08-27 18:30:00 UTC') },
{ id: 52, number: 16, title: 'Awesome 16', created_at: Time.parse('2024-08-25 12:00:00 UTC'),
merged_at: Time.parse('2024-08-27 18:30:00 UTC') }
{
id: 50, number: 12, title: 'Awesome 12',
created_at: Time.parse('2024-08-20 22:00:00 UTC'),
pull_request: { merged_at: Time.parse('2024-08-27 18:30:00 UTC') }
},
{
id: 51, number: 14, title: 'Awesome 14',
created_at: Time.parse('2024-08-23 12:00:00 UTC'),
pull_request: { merged_at: Time.parse('2024-08-27 18:30:00 UTC') }
},
{
id: 52, number: 16, title: 'Awesome 16',
created_at: Time.parse('2024-08-25 12:00:00 UTC'),
pull_request: { merged_at: Time.parse('2024-08-27 18:30:00 UTC') }
}
]
}
)
Expand All @@ -769,7 +796,7 @@ def test_quality_of_service_average_review_time_comments_reviewers_and_reviews
user: { login: 'yegor256', id: 526_301, type: 'User' },
state: 'CHANGES_REQUESTED',
author_association: 'CONTRIBUTOR',
submitted_at: Time.parse('2024-08-23 10:00:00 UTC')
submitted_at: nil
},
{
id: 22_449_327,
Expand Down Expand Up @@ -805,8 +832,7 @@ def test_quality_of_service_average_review_time_comments_reviewers_and_reviews
body: 'Some text 2',
user: { login: 'rultor', id: 526_303, type: 'Bot' },
state: 'CHANGES_REQUESTED',
author_association: 'CONTRIBUTOR',
submitted_at: Time.parse('2024-08-23 16:30:00 UTC')
author_association: 'CONTRIBUTOR'
},
{
id: 22_449_331,
Expand Down Expand Up @@ -1144,7 +1170,12 @@ def stub_workflow_runs(workflow_runs)
'q=repo:foo/foo%20type:pr%20is:merged%20closed:%3E2024-08-02',
body: {
total_count: 1, incomplete_results: false,
items: [{ id: 50, number: 12, title: 'Awesome 12', merged_at: Time.parse('2024-08-23 18:30:00 UTC') }]
items: [
{
id: 50, number: 12, title: 'Awesome 12',
pull_request: { merged_at: Time.parse('2024-08-23 18:30:00 UTC') }
}
]
}
)
stub_github(
Expand Down