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.
This commit is contained in:
Yorick Peterse 2015-10-14 14:53:06 +02:00
parent 8237da0d4a
commit b5f8161dae
1 changed files with 2 additions and 1 deletions

View File

@ -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