2013-03-28 13:02:59 -04:00
|
|
|
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.
|
2013-08-07 19:25:05 +02:00
|
|
|
class PeriodicalUpdates < Jobs::Scheduled
|
2014-02-06 10:14:41 +11:00
|
|
|
every 15.minutes
|
2013-03-28 13:02:59 -04:00
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
# Update the average times
|
2014-02-27 11:45:20 +11:00
|
|
|
Post.calculate_avg_time(1.day.ago)
|
|
|
|
Topic.calculate_avg_time(1.day.ago)
|
2013-03-28 13:02:59 -04:00
|
|
|
|
|
|
|
# Feature topics in categories
|
|
|
|
CategoryFeaturedTopic.feature_topics
|
|
|
|
|
|
|
|
# Update view counts for users
|
2013-10-04 13:28:49 +10:00
|
|
|
UserStat.update_view_counts
|
2013-03-28 13:02:59 -04:00
|
|
|
|
|
|
|
# Update the scores of posts
|
2014-02-27 11:45:20 +11:00
|
|
|
ScoreCalculator.new.calculate(1.day.ago)
|
2013-12-24 00:50:36 +01:00
|
|
|
|
2014-02-28 20:33:52 +01:00
|
|
|
# Update the scores of topics
|
|
|
|
TopTopic.refresh!
|
|
|
|
|
2013-11-11 10:52:44 +11:00
|
|
|
# Automatically close stuff that we missed
|
|
|
|
Topic.auto_close
|
2013-03-28 13:02:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|