diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-27 12:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-27 12:09:26 +0300 |
commit | 1f84ff323d6928b7be627484fdc88d5aa651f0f4 (patch) | |
tree | 835ac35954fc345e1ff5f9d3f1ff0b432b51a125 /app/finders | |
parent | 0d0fdf863c7b26e260342f704c48da90a4cb5605 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/issuable_finder.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 6bbbc237e62..5ca417455fb 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -316,7 +316,12 @@ class IssuableFinder # rubocop: disable CodeReuse/ActiveRecord def by_project(items) - if params.project? || params.projects + # When finding issues for multiple projects it's more efficient + # to use a JOIN instead of running a sub-query + # See https://gitlab.com/gitlab-org/gitlab/-/commit/8591cc02be6b12ed60f763a5e0147f2cbbca99e1 + if params.projects.is_a?(ActiveRecord::Relation) + items.merge(params.projects.reorder(nil)).join_project + elsif params.projects items.of_projects(params.projects).references_project else items.none |