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/explore/snippets_controller.rb | |
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/explore/snippets_controller.rb')
-rw-r--r-- | app/controllers/explore/snippets_controller.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/explore/snippets_controller.rb b/app/controllers/explore/snippets_controller.rb index 76ed142c939..6192b594593 100644 --- a/app/controllers/explore/snippets_controller.rb +++ b/app/controllers/explore/snippets_controller.rb @@ -1,8 +1,14 @@ # frozen_string_literal: true class Explore::SnippetsController < Explore::ApplicationController + include Gitlab::NoteableMetadata + def index - @snippets = SnippetsFinder.new(current_user).execute - @snippets = @snippets.page(params[:page]) + @snippets = SnippetsFinder.new(current_user) + .execute + .page(params[:page]) + .inc_author + + @noteable_meta_data = noteable_meta_data(@snippets, 'Snippet') end end |