Remove another N+1 query from categories page

This commit is contained in:
Neil Lalonde 2014-03-18 14:56:00 -04:00
parent 0b1550f9d4
commit fa4bc90fbb

View File

@ -40,6 +40,7 @@ class CategoryList
@topics_by_id = {}
@all_topics = Topic.where(id: category_featured_topics.map(&:topic_id))
@all_topics = @all_topics.includes(:last_poster) if include_latest_posts?
@all_topics.each do |t|
t.include_last_poster = true if include_latest_posts? # hint for serialization
@topics_by_id[t.id] = t