Commit edecab20 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'snippets-search-performance' into 'master'

Reduce query count for snippet search

See merge request !9254
parents 680d37b3 2a60f4de
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= snippet.title = snippet.title
by by
= link_to user_snippets_path(snippet.author) do = 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 = snippet.author_name
%span.light= time_ago_with_tooltip(snippet.created_at) %span.light= time_ago_with_tooltip(snippet.created_at)
%h4.snippet-title %h4.snippet-title
......
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
%span %span
by by
= link_to user_snippets_path(snippet_title.author) do = 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 = snippet_title.author_name
%span.light= time_ago_with_tooltip(snippet_title.created_at) %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 ...@@ -31,11 +31,11 @@ module Gitlab
private private
def snippet_titles def snippet_titles
limit_snippets.search(query).order('updated_at DESC') limit_snippets.search(query).order('updated_at DESC').includes(:author)
end end
def snippet_blobs def snippet_blobs
limit_snippets.search_code(query).order('updated_at DESC') limit_snippets.search_code(query).order('updated_at DESC').includes(:author)
end end
def default_scope 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