Skip to content
Snippets Groups Projects
Commit 2a60f4de authored by Phil Hughes's avatar Phil Hughes
Browse files

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
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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:
Loading
Loading
@@ -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
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