From 672d64c2ca89f3053d4383a5c6ec57947e0bcba1 Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Thu, 14 Nov 2019 14:36:20 -0600 Subject: [PATCH] Avoid N+1 queries when sending notifications for reactions (#4822) [deploy] --- app/services/notifications/reactions/send.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/notifications/reactions/send.rb b/app/services/notifications/reactions/send.rb index 2b092eb5a..3187c1e3b 100644 --- a/app/services/notifications/reactions/send.rb +++ b/app/services/notifications/reactions/send.rb @@ -24,7 +24,7 @@ module Notifications reaction_siblings = Reaction.where(reactable_id: reaction.reactable_id, reactable_type: reaction.reactable_type). where.not(reactions: { user_id: reaction.reactable_user_id }). - includes(:reactable). + includes(:reactable, :user). order("created_at DESC") aggregated_reaction_siblings = reaction_siblings.map { |reaction| { category: reaction.category, created_at: reaction.created_at, user: user_data(reaction.user) } }