Commit 3844ab70 authored by Stan Hu's avatar Stan Hu

Merge branch 'ce-avoid_n_plus_1_es_load_blobs' into 'master'

Backport of avoid_n_plus_1_es_load_blobs

See merge request gitlab-org/gitlab-ce!26522
parents 4fde1ba7 0401d00a
...@@ -33,10 +33,15 @@ module SearchHelper ...@@ -33,10 +33,15 @@ module SearchHelper
"Showing #{from} - #{to} of #{count} #{scope.humanize(capitalize: false)} for \"#{term}\"" "Showing #{from} - #{to} of #{count} #{scope.humanize(capitalize: false)} for \"#{term}\""
end end
def find_project_for_result_blob(result) def find_project_for_result_blob(projects, result)
@project @project
end end
# Used in EE
def blob_projects(results)
nil
end
def parse_search_result(result) def parse_search_result(result)
result result
end end
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
- if @scope == 'projects' - if @scope == 'projects'
.term .term
= render 'shared/projects/list', projects: @search_objects, pipeline_status: false = render 'shared/projects/list', projects: @search_objects, pipeline_status: false
- elsif %w[blobs wiki_blobs].include?(@scope)
= render partial: 'search/results/blob', collection: @search_objects, locals: { projects: blob_projects(@search_objects) }
- else - else
= render partial: "search/results/#{@scope.singularize}", collection: @search_objects = render partial: "search/results/#{@scope.singularize}", collection: @search_objects
......
- project = find_project_for_result_blob(blob) - project = find_project_for_result_blob(projects, blob)
- return unless project - return unless project
- blob = parse_search_result(blob) - blob = parse_search_result(blob)
......
- project = find_project_for_result_blob(wiki_blob) - project = find_project_for_result_blob(projects, wiki_blob)
- wiki_blob = parse_search_result(wiki_blob) - wiki_blob = parse_search_result(wiki_blob)
- wiki_blob_link = project_wiki_path(project, wiki_blob.basename) - wiki_blob_link = project_wiki_path(project, wiki_blob.basename)
......
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