mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
PERF: improve 'has_enough_topics_to_redirect_to_top' for high scale
This commit is contained in:
parent
737cb47307
commit
43496958fe
1 changed files with 4 additions and 1 deletions
|
@ -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 a new issue