summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-08-18 18:27:22 -0500
committerDouwe Maan <douwe@selenight.nl>2016-08-18 19:08:59 -0500
commit6a355d451eaca2fc10f5fcf31de13b05fa795b9b (patch)
treef758173d2911fd6ed34698068b90d59e34de5b8c /app/models/note.rb
parentac89bb0fad1d5820c4defd51cb6ab0626d1fb6ba (diff)
downloadgitlab-ce-6a355d451eaca2fc10f5fcf31de13b05fa795b9b.tar.gz
Improve performance of MR show page
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 79f7a247fba..3bbf5db0b70 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -25,6 +25,9 @@ class Note < ActiveRecord::Base
belongs_to :author, class_name: "User"
belongs_to :updated_by, class_name: "User"
+ # Only used by DiffNote, but defined here so that it can be used in `Note.includes`
+ belongs_to :resolved_by, class_name: "User"
+
has_many :todos, dependent: :destroy
has_many :events, as: :target, dependent: :destroy
@@ -59,7 +62,7 @@ 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 :inc_relations_for_view, ->{ includes(:project, :author, :updated_by, :resolved_by, :award_emoji) }
scope :diff_notes, ->{ where(type: ['LegacyDiffNote', 'DiffNote']) }
scope :non_diff_notes, ->{ where(type: ['Note', nil]) }