A platform for community discussion. Free, open, simple.
FEATURE: exclude muted categories from the "top" topics list.
Vinoth Kannan744bbf6904e9
diff --git a/lib/topic_query.rb b/lib/topic_query.rbindex 772ea5af28b..5f8658661b4 100644--- a/lib/topic_query.rb+++ b/lib/topic_query.rb@@ -265,6 +265,7 @@ class TopicQuerydef list_top_for(period)score = "#{period}_score"create_list(:top, unordered: true) do |topics|+ topics = remove_muted_categories(topics, @user)topics = topics.joins(:top_topic).where("top_topics.#{score} > 0")if period == :yearly && @user.try(:trust_level) == TrustLevel[0]topics.order(TopicQuerySQL.order_top_with_pinned_category_for(score))diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rbindex 0bafbbb1b34..d6e56a069de 100644--- a/spec/components/topic_query_spec.rb+++ b/spec/components/topic_query_spec.rb@@ -265,7 +265,7 @@ describe TopicQuery doendcontext 'muted categories' do- it 'is removed from new and latest lists' do+ it 'is removed from top, new and latest lists' docategory = Fabricate(:category_with_definition)topic = Fabricate(:topic, category: category)CategoryUser.create!(user_id: user.id,@@ -273,6 +273,8 @@ describe TopicQuery donotification_level: CategoryUser.notification_levels[:muted])expect(topic_query.list_new.topics.map(&:id)).not_to include(topic.id)expect(topic_query.list_latest.topics.map(&:id)).not_to include(topic.id)+ TopTopic.create!(topic: topic, all_score: 1)+ expect(topic_query.list_top_for(:all).topics.map(&:id)).not_to include(topic.id)endend