diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-10-13 11:49:01 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-10-15 12:05:01 +0200 |
commit | 1554786c6ac49b452697d2f7a3e8daf6e3ac36d3 (patch) | |
tree | 47393db31476e5c7022350463e74a2cb6deb8ed3 /app/models/concerns | |
parent | ff8f7fb0a111a5db2a50aa40e967cae699b0b245 (diff) | |
download | gitlab-ce-1554786c6ac49b452697d2f7a3e8daf6e3ac36d3.tar.gz |
Eager load various issue/note associations
This ensures we don't end up running N+1 queries for the objects in the
affected collections.
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/issuable.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 4db4ffb2e79..0e8bcc1a4ec 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -47,7 +47,8 @@ module Issuable prefix: true attr_mentionable :title, :description - participant :author, :assignee, :notes, :mentioned_users + + participant :author, :assignee, :notes_with_associations, :mentioned_users end module ClassMethods @@ -176,6 +177,10 @@ module Issuable self.class.to_s.underscore end + def notes_with_associations + notes.includes(:author, :project) + end + private def filter_superceded_votes(votes, notes) |