summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab/search_results.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index b46c18c4364..458737f31eb 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -18,6 +18,11 @@ module Gitlab
@data = encode_utf8(opts.fetch(:data, nil))
@per_page = opts.fetch(:per_page, 20)
@project = opts.fetch(:project, nil)
+ # Some caller does not have project object (e.g. elastic search),
+ # yet they can trigger many calls in one go,
+ # causing duplicated queries.
+ # Allow those to just pass project_id instead.
+ @project_id = opts.fetch(:project_id, nil)
end
def path
@@ -25,7 +30,7 @@ module Gitlab
end
def project_id
- @project&.id
+ @project_id || @project&.id
end
def present