diff options
author | Markus Koller <mkoller@gitlab.com> | 2019-09-02 14:12:20 +0300 |
---|---|---|
committer | Markus Koller <mkoller@gitlab.com> | 2019-09-10 16:24:28 +0300 |
commit | 60755fbc406bd25ab526339899f97a2b27aeb272 (patch) | |
tree | a60f6fa9beb0c4ccdc27c5f7734c14bc34ad2d21 /app/controllers/dashboard | |
parent | 08b0613302ec813c0735e2c0447a3f7683d7ab87 (diff) |
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.rb | 14 |
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 |