From 53ec4c44f498ac51410e949b16b2782163cd696d Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 22 Feb 2017 12:20:50 -0500 Subject: [PATCH] FIX: N+1 in topic_list --- app/models/topic_list.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/topic_list.rb b/app/models/topic_list.rb index 16dc5ea6e27..9fbc99142a8 100644 --- a/app/models/topic_list.rb +++ b/app/models/topic_list.rb @@ -101,6 +101,7 @@ class TopicList end avatar_lookup = AvatarLookup.new(user_ids) + primary_group_lookup = PrimaryGroupLookup.new(user_ids) @topics.each do |ft| ft.user_data = @topic_lookup[ft.id] if @topic_lookup.present? @@ -111,7 +112,7 @@ class TopicList ft.posters = ft.posters_summary( avatar_lookup: avatar_lookup, - primary_group_lookup: PrimaryGroupLookup.new(user_ids) + primary_group_lookup: primary_group_lookup ) ft.participants = ft.participants_summary(avatar_lookup: avatar_lookup, user: @current_user)