mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: make score calculator cheaper when site has long topics
This commit is contained in:
@@ -7,12 +7,22 @@ module Jobs
|
||||
class PeriodicalUpdates < Jobs::Scheduled
|
||||
every 15.minutes
|
||||
|
||||
def self.should_update_long_topics?
|
||||
@call_count ||= 0
|
||||
@call_count += 1
|
||||
|
||||
# once every 6 hours
|
||||
(@call_count % 24) == 1
|
||||
end
|
||||
|
||||
def execute(args)
|
||||
# Feature topics in categories
|
||||
CategoryFeaturedTopic.feature_topics
|
||||
|
||||
# Update the scores of posts
|
||||
ScoreCalculator.new.calculate(1.day.ago)
|
||||
args = {min_topic_age: 1.day.ago}
|
||||
args[:max_topic_length] = 500 unless self.class.should_update_long_topics?
|
||||
ScoreCalculator.new.calculate(args)
|
||||
|
||||
# Automatically close stuff that we missed
|
||||
Topic.auto_close
|
||||
|
||||
Reference in New Issue
Block a user