Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/labels_finder.rb')
-rw-r--r--app/finders/labels_finder.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index 9f9d0da6efd..b1387f2a104 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -11,6 +11,11 @@ class LabelsFinder < UnionFinder
def initialize(current_user, params = {})
@current_user = current_user
@params = params
+ # Preload container records (project, group) by default, in some cases we invoke
+ # the LabelsPreloader on the loaded records to prevent all N+1 queries.
+ # In that case we disable the default with_preloaded_container scope because it
+ # interferes with the LabelsPreloader.
+ @preload_parent_association = params.fetch(:preload_parent_association, true)
end
def execute(skip_authorization: false)
@@ -19,7 +24,9 @@ class LabelsFinder < UnionFinder
items = with_title(items)
items = by_subscription(items)
items = by_search(items)
- sort(items.with_preloaded_container)
+
+ items = items.with_preloaded_container if @preload_parent_association
+ sort(items)
end
private