Commit e73fc904 authored by Mark Chao's avatar Mark Chao

Allow search results to accept project_id

This gives flexiblity to avoid duplicated query of Project.
parent bf93f3de
...@@ -18,6 +18,11 @@ module Gitlab ...@@ -18,6 +18,11 @@ module Gitlab
@data = encode_utf8(opts.fetch(:data, nil)) @data = encode_utf8(opts.fetch(:data, nil))
@per_page = opts.fetch(:per_page, 20) @per_page = opts.fetch(:per_page, 20)
@project = opts.fetch(:project, nil) @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 end
def path def path
...@@ -25,7 +30,7 @@ module Gitlab ...@@ -25,7 +30,7 @@ module Gitlab
end end
def project_id def project_id
@project&.id @project_id || @project&.id
end end
def present def present
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment