diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-02-06 13:20:42 +0100 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-02-07 00:22:13 +0100 |
commit | f7c30ae30d878de3980f65a2c3353503a440a615 (patch) | |
tree | 0b6b6b1fd7393aa3d7cb940796c783a9f6613100 | |
parent | b9d547b12c3731160c456f3f20366e600ab99484 (diff) | |
download | gitlab-ce-40755-snippets-author-n+1.tar.gz |
Fix N+1 query problem for snippets dashboard.40755-snippets-author-n+1
Closes #40755.
-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 |