diff options
-rw-r--r-- | app/finders/snippets_finder.rb | 2 | ||||
-rw-r--r-- | app/views/shared/snippets/_snippet.html.haml | 2 | ||||
-rw-r--r-- | changelogs/unreleased/40755-snippets-author-n-1.yml | 5 |
3 files changed, 7 insertions, 2 deletions
diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb index c04f61de79c..4450766485f 100644 --- a/app/finders/snippets_finder.rb +++ b/app/finders/snippets_finder.rb @@ -28,7 +28,7 @@ class SnippetsFinder < UnionFinder segments << items.public_to_user(current_user) segments << authorized_to_user(items) if current_user - find_union(segments, Snippet) + find_union(segments, Snippet.includes(:author)) end def authorized_to_user(items) diff --git a/app/views/shared/snippets/_snippet.html.haml b/app/views/shared/snippets/_snippet.html.haml index 7388f20a9fd..57b445321e2 100644 --- a/app/views/shared/snippets/_snippet.html.haml +++ b/app/views/shared/snippets/_snippet.html.haml @@ -1,7 +1,7 @@ - link_project = local_assigns.fetch(:link_project, false) %li.snippet-row - = image_tag avatar_icon(snippet.author_email), class: "avatar s40 hidden-xs", alt: '' + = image_tag avatar_icon(snippet.author), class: "avatar s40 hidden-xs", alt: '' .title = link_to reliable_snippet_path(snippet) do diff --git a/changelogs/unreleased/40755-snippets-author-n-1.yml b/changelogs/unreleased/40755-snippets-author-n-1.yml new file mode 100644 index 00000000000..6e09c8a54ec --- /dev/null +++ b/changelogs/unreleased/40755-snippets-author-n-1.yml @@ -0,0 +1,5 @@ +--- +title: Fix N+1 query problem for snippets dashboard. +merge_request: 16944 +author: +type: performance |