diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-06-21 07:26:43 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-06-23 21:04:37 +0200 |
commit | 66ec925557d63f3f168b03a8b85e15a199da7307 (patch) | |
tree | ad2ca58f602870e9aa0c7c7dc34805123f87ade0 /app/models/note.rb | |
parent | e7a27946ea6e165eac99098be6dbe8e6a408da4a (diff) | |
download | gitlab-ce-66ec925557d63f3f168b03a8b85e15a199da7307.tar.gz |
Preload notes/discussions associations (award_emoji: :user)optimize-award-emoji
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 4bc9d1a92f8..e510525b89d 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -49,12 +49,14 @@ class Note < ActiveRecord::Base scope :fresh, ->{ order(created_at: :asc, id: :asc) } scope :inc_author_project, ->{ includes(:project, :author) } scope :inc_author, ->{ includes(:author) } + scope :inc_author_project_award_emoji, ->{ includes(:project, :author, :award_emoji) } scope :legacy_diff_notes, ->{ where(type: 'LegacyDiffNote') } scope :non_diff_notes, ->{ where(type: ['Note', nil]) } scope :with_associations, -> do - includes(:author, :noteable, :updated_by, :award_emoji, + # FYI noteable cannot be loaded for LegacyDiffNote for commits + includes(:author, :noteable, :updated_by, project: [:project_members, { group: [:group_members] }]) end |