From b018b4ad1811aed9df183dbabb31f7b465507148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 12 May 2014 10:11:05 +0200 Subject: [PATCH] BUGFIX: remove N+1 on topic lists --- app/models/topic_list.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/topic_list.rb b/app/models/topic_list.rb index 92c8e3f6602..a6b0b4a4fff 100644 --- a/app/models/topic_list.rb +++ b/app/models/topic_list.rb @@ -22,7 +22,11 @@ class TopicList # copy side-loaded data (allowed users) before dumping it with the .to_a @topics_input.each do |t| - t.allowed_user_ids = t.allowed_users.map { |u| u.id }.to_a + t.allowed_user_ids = if @filter == :private_messages + t.allowed_users.map { |u| u.id }.to_a + else + [] + end end @topics = @topics_input.to_a