Include user relationship when retrieving award_emoji
Avoiding N+1 when showing grouped awards and when calculating participants for awardable entities
This commit is contained in:
parent
bf4455d146
commit
52a2b8a410
|
@ -90,6 +90,7 @@ v 8.9.0 (unreleased)
|
|||
- Horizontally scrolling navigation on project, group, and profile settings pages
|
||||
- Hide global side navigation by default
|
||||
- Remove tanuki logo from side navigation; center on top nav
|
||||
- Include user relationships when retrieving award_emoji
|
||||
|
||||
v 8.8.5 (unreleased)
|
||||
- Ensure branch cleanup regardless of whether the GitHub import process succeeds
|
||||
|
|
|
@ -5,7 +5,7 @@ module Awardable
|
|||
has_many :award_emoji, as: :awardable, dependent: :destroy
|
||||
|
||||
if self < Participable
|
||||
participant :award_emoji
|
||||
participant :award_emoji_with_associations
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,8 +34,12 @@ module Awardable
|
|||
end
|
||||
end
|
||||
|
||||
def award_emoji_with_associations
|
||||
award_emoji.includes(:user)
|
||||
end
|
||||
|
||||
def grouped_awards(with_thumbs: true)
|
||||
awards = award_emoji.group_by(&:name)
|
||||
awards = award_emoji_with_associations.group_by(&:name)
|
||||
|
||||
if with_thumbs
|
||||
awards[AwardEmoji::UPVOTE_NAME] ||= []
|
||||
|
|
Loading…
Reference in New Issue