FIX: remove muted categories from suggested

This commit is contained in:
Sam 2014-07-29 14:34:54 +10:00
parent 7c83823a95
commit 8c68309b5a

View File

@ -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")