diff options
author | Mark Chao <mchao@gitlab.com> | 2018-10-16 13:56:13 +0800 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-10-30 15:44:55 +0800 |
commit | 0fa5260f1d1e99bcd0429cba09140c039a3d9d5a (patch) | |
tree | 197bf21206c6992261beaaa229d542891baba30a | |
parent | 623b7f3055e0dec033795b9d4eb625b781773834 (diff) | |
download | gitlab-ce-add-language-param-to-highlight.tar.gz |
Allow search results to accept project_idadd-language-param-to-highlight
This gives flexiblity to avoid duplicated query of Project.
-rw-r--r-- | lib/gitlab/search_results.rb | 7 |
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 |