From 3e123b1a399a05d1f501ae0caf1e558fdbcc1420 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 7 Sep 2017 17:22:39 +0800 Subject: [PATCH] PERF: Use `pluck` instead of enmurating through all the records. --- lib/topic_view.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/topic_view.rb b/lib/topic_view.rb index 9a268f96682..0e072f9d779 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -68,11 +68,11 @@ class TopicView if @posts if (added_fields = User.whitelisted_user_custom_fields(@guardian)).present? - @user_custom_fields = User.custom_fields_for_ids(@posts.map(&:user_id), added_fields) + @user_custom_fields = User.custom_fields_for_ids(@posts.pluck(:user_id), added_fields) end if (whitelisted_fields = TopicView.whitelisted_post_custom_fields(@user)).present? - @post_custom_fields = Post.custom_fields_for_ids(@posts.map(&:id), whitelisted_fields) + @post_custom_fields = Post.custom_fields_for_ids(@posts.pluck(:id), whitelisted_fields) end end