A platform for community discussion. Free, open, simple.
PERF: Remove redundant DB queries from `TopicView` (#19658)
Alan Guo Xiang Tanbe1ae9411b16
diff --git a/lib/topic_view.rb b/lib/topic_view.rbindex b963b5c59db..eeccb8bae89 100644--- a/lib/topic_view.rb+++ b/lib/topic_view.rb@@ -139,11 +139,11 @@ class TopicViewif @posts && !@skip_custom_fieldsif (added_fields = User.allowed_user_custom_fields(@guardian)).present?- @user_custom_fields = User.custom_fields_for_ids(@posts.pluck(:user_id), added_fields)+ @user_custom_fields = User.custom_fields_for_ids(@posts.map(&:user_id), added_fields)endif (allowed_fields = TopicView.allowed_post_custom_fields(@user, @topic)).present?- @post_custom_fields = Post.custom_fields_for_ids(@posts.pluck(:id), allowed_fields)+ @post_custom_fields = Post.custom_fields_for_ids(@posts.map(&:id), allowed_fields)endend@@ -778,7 +778,6 @@ class TopicView:reply_to_user,:deleted_by,:incoming_email,- :topic,:image_upload)