diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/noteable.rb | 4 | ||||
-rw-r--r-- | app/models/snippet.rb | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb index 6a44bc7c401..b3e4df730b4 100644 --- a/app/models/concerns/noteable.rb +++ b/app/models/concerns/noteable.rb @@ -3,6 +3,10 @@ module Noteable extend ActiveSupport::Concern + # This object is used to gather noteable meta data for list displays + # avoiding n+1 queries and improving performance. + NoteableMeta = Struct.new(:user_notes_count) + class_methods do # `Noteable` class names that support replying to individual notes. def replyable_types diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 00931457344..b2fca65b9e0 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -55,6 +55,7 @@ class Snippet < ApplicationRecord scope :are_public, -> { where(visibility_level: Snippet::PUBLIC) } scope :public_and_internal, -> { where(visibility_level: [Snippet::PUBLIC, Snippet::INTERNAL]) } scope :fresh, -> { order("created_at DESC") } + scope :inc_author, -> { includes(:author) } scope :inc_relations_for_view, -> { includes(author: :status) } participant :author |