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:
authorMark Chao <mchao@gitlab.com>2018-10-16 08:56:13 +0300
committerMark Chao <mchao@gitlab.com>2018-10-30 10:44:55 +0300
commit0fa5260f1d1e99bcd0429cba09140c039a3d9d5a (patch)
tree197bf21206c6992261beaaa229d542891baba30a /lib/gitlab/search_results.rb
parent623b7f3055e0dec033795b9d4eb625b781773834 (diff)
Allow search results to accept project_id
This gives flexiblity to avoid duplicated query of Project.
Diffstat (limited to 'lib/gitlab/search_results.rb')
-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