PERF: only rebuild entire top topic table daily

This commit is contained in:
Sam 2014-02-27 11:44:03 +11:00
parent cceed615a3
commit e4909c017c
2 changed files with 19 additions and 2 deletions

View file

@ -0,0 +1,19 @@
require_dependency 'score_calculator'
module Jobs
# This job will run on a regular basis to update statistics and denormalized data.
# If it does not run, the site will not function properly.
class PeriodicalUpdates < Jobs::Scheduled
every 1.day
def execute(args)
# TODO: optimise this against a big site before doing this any more
# frequently
#
# current implementation wipes an entire table and rebuilds causing huge
# amounts of IO
TopTopic.refresh!
end
end
end

View file

@ -21,8 +21,6 @@ module Jobs
# Update the scores of posts # Update the scores of posts
ScoreCalculator.new.calculate ScoreCalculator.new.calculate
# Refresh Top Topics
TopTopic.refresh!
# Automatically close stuff that we missed # Automatically close stuff that we missed
Topic.auto_close Topic.auto_close