Commit d1a38c9b authored by Pavel Shutsin's avatar Pavel Shutsin

Fix productivity analytics with multiple labels

Scatterplot chart API should properly
handle multiple label searches starting from now
parent c9d28cea
......@@ -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