PERF: cache category topic ids

This commit is contained in:
Sam
2016-07-19 12:34:54 +10:00
parent c1a01b2a28
commit 1c964bf730
3 changed files with 17 additions and 2 deletions

View File

@ -699,7 +699,7 @@ class TopicQuery
def random_suggested(topic, count, excluded_topic_ids=[])
result = default_results(unordered: true, per_page: count).where(closed: false, archived: false)
excluded_topic_ids += Category.pluck(:topic_id).compact
excluded_topic_ids += Category.topic_ids.to_a
result = result.where("topics.id NOT IN (?)", excluded_topic_ids) unless excluded_topic_ids.empty?
result = remove_muted_categories(result, @user)