Skip to content

A platform for community discussion. Free, open, simple.

PERF: Remove unnecessary query from `TopicQuery.remove_muted_tags` (#19586)

Alan Guo Xiang Tana8ee56ebee6d
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?