Skip to content
Snippets Groups Projects
Commit 0df9439e authored by Mark Chao's avatar Mark Chao
Browse files

Allow search results to accept project_id

This gives flexiblity to avoid duplicated query of Project.
parent 11db1f41
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -16,6 +16,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
Loading
Loading
@@ -23,7 +28,7 @@ module Gitlab
end
 
def project_id
@project&.id
@project_id || @project&.id
end
 
def present
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment