PERF: improve 'has_enough_topics_to_redirect_to_top' for high scale
This commit is contained in:
parent
737cb47307
commit
43496958fe
|
@ -88,7 +88,10 @@ class SiteSetting < ActiveRecord::Base
|
|||
|
||||
def self.has_enough_topics_to_redirect_to_top
|
||||
TopTopic.periods.each do |period|
|
||||
return true if TopTopic.where("#{period}_score > 0").count >= SiteSetting.topics_per_period_in_top_page
|
||||
topics_per_period = TopTopic.where("#{period}_score > 0")
|
||||
.limit(SiteSetting.topics_per_period_in_top_page)
|
||||
.count
|
||||
return true if topics_per_period >= SiteSetting.topics_per_period_in_top_page
|
||||
end
|
||||
# nothing
|
||||
false
|
||||
|
|
Loading…
Reference in New Issue