summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2015-10-14 14:53:06 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2015-10-15 12:05:01 +0200
commitb5f8161daeefeaa66e810e9dddec43959333d8a7 (patch)
tree53a77ff2623a21a45cdbfd658e40f85042bad47a
parent8237da0d4a250b4cb07e85caac3c43e11e282ebb (diff)
downloadgitlab-ce-b5f8161daeefeaa66e810e9dddec43959333d8a7.tar.gz
Eager load project associations for notes
This ensures that when viewing an issue each note already has the associated project, project members, group and group members available. Since this information is requres for every note this results in quite the reduction of SQL queries being executed.
-rw-r--r--app/models/note.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index d0b30c55791..196512c4715 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -61,7 +61,8 @@ class Note < ActiveRecord::Base
scope :inc_author, ->{ includes(:author) }
scope :inc_associations, -> do
- includes(:author, :noteable, :updated_by, :project)
+ includes(:author, :noteable, :updated_by,
+ project: [:project_members, {group: [:group_members]}])
end
serialize :st_diff