diff --git a/lib/topic_query.rb b/lib/topic_query.rb index f4c84ccaebe..366d3affc0a 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -313,7 +313,7 @@ class TopicQuery result end - def remove_muted_categories(list, user, opts) + def remove_muted_categories(list, user, opts=nil) category_id = get_category_id(opts[:exclude]) if opts if user list = list.where("NOT EXISTS( @@ -352,6 +352,8 @@ class TopicQuery excluded_topic_ids += Category.pluck(:topic_id).compact result = result.where("topics.id NOT IN (?)", excluded_topic_ids) unless excluded_topic_ids.empty? + result = remove_muted_categories(result, @user) + # If we are in a category, prefer it for the random results if topic.category_id result = result.order("CASE WHEN topics.category_id = #{topic.category_id.to_i} THEN 0 ELSE 1 END")