summaryrefslogtreecommitdiff
path: root/app/controllers/dashboard
diff options
context:
space:
mode:
authorMarkus Koller <mkoller@gitlab.com>2019-09-02 13:12:20 +0200
committerMarkus Koller <mkoller@gitlab.com>2019-09-10 15:24:28 +0200
commit60755fbc406bd25ab526339899f97a2b27aeb272 (patch)
treea60f6fa9beb0c4ccdc27c5f7734c14bc34ad2d21 /app/controllers/dashboard
parent08b0613302ec813c0735e2c0447a3f7683d7ab87 (diff)
downloadgitlab-ce-60755fbc406bd25ab526339899f97a2b27aeb272.tar.gz
Optimize queries for snippet listings
- Avoid N+1 queries for authors and comment counts - Avoid an additional snippet existence query
Diffstat (limited to 'app/controllers/dashboard')
-rw-r--r--app/controllers/dashboard/snippets_controller.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/controllers/dashboard/snippets_controller.rb b/app/controllers/dashboard/snippets_controller.rb
index 161c22046f9..382f54c6c00 100644
--- a/app/controllers/dashboard/snippets_controller.rb
+++ b/app/controllers/dashboard/snippets_controller.rb
@@ -1,14 +1,16 @@
# frozen_string_literal: true
class Dashboard::SnippetsController < Dashboard::ApplicationController
+ include Gitlab::NoteableMetadata
+
skip_cross_project_access_check :index
def index
- @snippets = SnippetsFinder.new(
- current_user,
- author: current_user,
- scope: params[:scope]
- ).execute
- @snippets = @snippets.page(params[:page])
+ @snippets = SnippetsFinder.new(current_user, author: current_user, scope: params[:scope])
+ .execute
+ .page(params[:page])
+ .inc_author
+
+ @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet')
end
end