Commit d9d063b9 authored by James Lopez's avatar James Lopez

Merge branch '38031-fix-productivity-analytics-scatterplot-call' into 'master'

Fix productivity analytics scatterplot with multiple labels

Closes #38031

See merge request gitlab-org/gitlab!21301
parents c27d5b9c d1a38c9b
......@@ -60,10 +60,9 @@ class ProductivityAnalytics
end
def scatterplot_query(column)
merge_requests
.except(:select)
MergeRequest::Metrics.joins(:merge_request).where(merge_request_id: merge_requests)
.select("#{column} as metric, merge_requests.id, merge_request_metrics.merged_at")
.reorder("merge_request_metrics.merged_at ASC")
.order("merge_request_metrics.merged_at ASC, id ASC")
end
def sorting
......
......@@ -170,6 +170,20 @@ describe ProductivityAnalytics do
long_mr.id => { metric: 30, merged_at: be_like_time(long_mr.merged_at) }
)
end
context 'for multiple labeled mrs' do
let(:finder_options) { super().merge(label_name: [label_a.title, label_b.title]) }
it 'properly returns MRs with metrics calculated' do
expected_data = {
long_mr.id => { metric: 30, merged_at: be_like_time(long_mr.merged_at) },
short_mr.id => { metric: 3, merged_at: be_like_time(short_mr.merged_at) },
short_mr_2.id => { metric: 3, merged_at: be_like_time(short_mr_2.merged_at) }
}
expect(scatterplot_data).to match(expected_data)
end
end
end
describe '#merge_requests_extended' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment