Commit 52a2b8a4 authored by Paco Guzman's avatar Paco Guzman

Include user relationship when retrieving award_emoji

Avoiding N+1 when showing grouped awards and when 
calculating participants for awardable entities
parent bf4455d1
......@@ -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] ||= []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment