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,7 +4,6 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
||||||
|
|
||||||
# Populates the category featured topics
|
# Populates the category featured topics
|
||||||
def self.feature_topics
|
def self.feature_topics
|
||||||
transaction do
|
|
||||||
current = {}
|
current = {}
|
||||||
CategoryFeaturedTopic.select(:topic_id, :category_id).order(:rank).each do |f|
|
CategoryFeaturedTopic.select(:topic_id, :category_id).order(:rank).each do |f|
|
||||||
(current[f.category_id] ||= []) << f.topic_id
|
(current[f.category_id] ||= []) << f.topic_id
|
||||||
|
@ -13,7 +12,6 @@ class CategoryFeaturedTopic < ActiveRecord::Base
|
||||||
CategoryFeaturedTopic.feature_topics_for(c, current[c.id] || [])
|
CategoryFeaturedTopic.feature_topics_for(c, current[c.id] || [])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def self.feature_topics_for(c, existing=nil)
|
def self.feature_topics_for(c, existing=nil)
|
||||||
return if c.blank?
|
return if c.blank?
|
||||||
|
|
Loading…
Reference in New Issue