Commit 7e91780e authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'issue_198156' into 'master'

Fix epics search query

See merge request gitlab-org/gitlab!28380
parents 51aad1dd dcdbc377
...@@ -55,7 +55,6 @@ class EpicsFinder < IssuableFinder ...@@ -55,7 +55,6 @@ class EpicsFinder < IssuableFinder
items = init_collection items = init_collection
items = by_created_at(items) items = by_created_at(items)
items = by_updated_at(items) items = by_updated_at(items)
items = by_search(items)
items = by_author(items) items = by_author(items)
items = by_timeframe(items) items = by_timeframe(items)
items = by_state(items) items = by_state(items)
...@@ -64,6 +63,12 @@ class EpicsFinder < IssuableFinder ...@@ -64,6 +63,12 @@ class EpicsFinder < IssuableFinder
items = by_iids(items) items = by_iids(items)
items = starts_with_iid(items) items = starts_with_iid(items)
# This has to be last as we use a CTE as an optimization fence
# for counts by passing the force_cte param and enabling the
# attempt_group_search_optimizations feature flag
# https://www.postgresql.org/docs/current/static/queries-with.html
items = by_search(items)
sort(items) sort(items)
end end
......
...@@ -272,6 +272,21 @@ describe EpicsFinder do ...@@ -272,6 +272,21 @@ describe EpicsFinder do
expect { epics(iid_starts_with: '-1') }.to raise_error(ArgumentError) expect { epics(iid_starts_with: '-1') }.to raise_error(ArgumentError)
end end
end end
context 'when using group cte for search' do
context 'and two labels more search string are present' do
let_it_be(:label1) { create(:label) }
let_it_be(:label2) { create(:label) }
let!(:labeled_epic) { create(:labeled_epic, group: group, title: 'filtered epic', labels: [label1, label2]) }
it 'returns correct epics' do
filtered_epics =
epics(attempt_group_search_optimizations: true, label_name: [label1.title, label2.title], search: 'filtered')
expect(filtered_epics).to contain_exactly(labeled_epic)
end
end
end
end 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