2013-03-29 01:02:59 +08: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-08 01:25:05 +08:00
|
|
|
class PeriodicalUpdates < Jobs::Scheduled
|
2013-09-30 14:59:16 +08:00
|
|
|
recurrence { hourly.minute_of_hour(3, 18, 33, 48) }
|
2013-03-29 01:02:59 +08:00
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
# Update the average times
|
|
|
|
Post.calculate_avg_time
|
|
|
|
Topic.calculate_avg_time
|
|
|
|
|
|
|
|
# Feature topics in categories
|
|
|
|
CategoryFeaturedTopic.feature_topics
|
|
|
|
|
|
|
|
# Update view counts for users
|
2013-10-04 11:28:49 +08:00
|
|
|
UserStat.update_view_counts
|
2013-03-29 01:02:59 +08:00
|
|
|
|
|
|
|
# Update the scores of posts
|
|
|
|
ScoreCalculator.new.calculate
|
|
|
|
|
2013-12-24 07:50:36 +08:00
|
|
|
# Refresh Top Topics
|
|
|
|
TopTopic.refresh!
|
|
|
|
|
2013-11-11 07:52:44 +08:00
|
|
|
# Automatically close stuff that we missed
|
|
|
|
Topic.auto_close
|
2013-03-29 01:02:59 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|