Commit 45547ec4 authored by Adam Hegyi's avatar Adam Hegyi

Fix PG::GroupingError with label filters

This change fixes the PG::GroupingError when two label filters are given
in the merge request analytics filters.
parent 862f6bf8
......@@ -352,12 +352,15 @@ module Issuable
#
# Returns an array of arel columns
def grouping_columns(sort)
sort = sort.to_s
grouping_columns = [arel_table[:id]]
if %w(milestone_due_desc milestone_due_asc milestone).include?(sort)
milestone_table = Milestone.arel_table
grouping_columns << milestone_table[:id]
grouping_columns << milestone_table[:due_date]
elsif %w(merged_at_desc merged_at_asc).include?(sort)
grouping_columns << MergeRequest::Metrics.arel_table[:merged_at]
end
grouping_columns
......
---
title: Fix merge request analytics page filtering when multiple labels are given
merge_request: 51060
author:
type: fixed
......@@ -231,6 +231,16 @@ RSpec.describe Resolvers::MergeRequestsResolver do
it 'sorts merge requests descending' do
expect(resolve_mr(project, sort: :merged_at_desc)).to eq [merge_request_3, merge_request_1, merge_request_with_milestone, merge_request_6, merge_request_5, merge_request_4, merge_request_2]
end
context 'when label filter is given and the optimized_issuable_label_filter feature flag is off' do
before do
stub_feature_flags(optimized_issuable_label_filter: false)
end
it 'does not raise PG::GroupingError' do
expect { resolve_mr(project, sort: :merged_at_desc, labels: %w[a b]) }.not_to raise_error
end
end
end
end
end
......
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