From a8ee56ebee6dd10b3c9604f338559401c8a8e6f1 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan <gxtan1990@gmail.com> Date: Fri, 23 Dec 2022 04:29:17 +0800 Subject: [PATCH] PERF: Remove unnecessary query from `TopicQuery.remove_muted_tags` (#19586) When `default_tags_muted` site settings has not been set, there is no need to execute the query. --- lib/topic_query.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index c5b5b84b94e..635f05c7d7a 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -899,7 +899,10 @@ class TopicQuery muted_tag_ids = TagUser.lookup(user, :muted).pluck(:tag_id) else muted_tag_names = SiteSetting.default_tags_muted.split("|") - muted_tag_ids = Tag.where(name: muted_tag_names).pluck(:id) + + if muted_tag_names.present? + muted_tag_ids = Tag.where(name: muted_tag_names).pluck(:id) + end end if muted_tag_ids.blank?