Commit 2a60f4de authored by Phil Hughes's avatar Phil Hughes

Reduce query count for snippet search

Recudes the number of queries within the snippet search from approx. 50
to approx. 14 by preloading the authors

Part of #27392
parent 6038355f
......@@ -7,7 +7,7 @@
= snippet.title
by
= link_to user_snippets_path(snippet.author) do
= image_tag avatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: ''
= image_tag avatar_icon(snippet.author), class: "avatar avatar-inline s16", alt: ''
= snippet.author_name
%span.light= time_ago_with_tooltip(snippet.created_at)
%h4.snippet-title
......
......@@ -18,6 +18,6 @@
%span
by
= link_to user_snippets_path(snippet_title.author) do
= image_tag avatar_icon(snippet_title.author_email), class: "avatar avatar-inline s16", alt: ''
= image_tag avatar_icon(snippet_title.author), class: "avatar avatar-inline s16", alt: ''
= snippet_title.author_name
%span.light= time_ago_with_tooltip(snippet_title.created_at)
---
title: Reduced query count for snippet search
merge_request:
author:
......@@ -31,11 +31,11 @@ module Gitlab
private
def snippet_titles
limit_snippets.search(query).order('updated_at DESC')
limit_snippets.search(query).order('updated_at DESC').includes(:author)
end
def snippet_blobs
limit_snippets.search_code(query).order('updated_at DESC')
limit_snippets.search_code(query).order('updated_at DESC').includes(:author)
end
def default_scope
......
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