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
@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
......
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