PERF: no need to nest a transaction when featuring topics
adding featured topics is already in a transaction, no need to nest
This commit is contained in:
parent
4cef1c1750
commit
9893953f62
|
@ -4,14 +4,12 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
|||
|
||||
# Populates the category featured topics
|
||||
def self.feature_topics
|
||||
transaction do
|
||||
current = {}
|
||||
CategoryFeaturedTopic.select(:topic_id, :category_id).order(:rank).each do |f|
|
||||
(current[f.category_id] ||= []) << f.topic_id
|
||||
end
|
||||
Category.select(:id, :topic_id).find_each do |c|
|
||||
CategoryFeaturedTopic.feature_topics_for(c, current[c.id] || [])
|
||||
end
|
||||
current = {}
|
||||
CategoryFeaturedTopic.select(:topic_id, :category_id).order(:rank).each do |f|
|
||||
(current[f.category_id] ||= []) << f.topic_id
|
||||
end
|
||||
Category.select(:id, :topic_id).find_each do |c|
|
||||
CategoryFeaturedTopic.feature_topics_for(c, current[c.id] || [])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue