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
|
2014-02-06 07:14:41 +08:00
|
|
|
every 15.minutes
|
2013-03-29 01:02:59 +08:00
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
# Update the average times
|
2014-02-27 08:45:20 +08:00
|
|
|
Post.calculate_avg_time(1.day.ago)
|
|
|
|
Topic.calculate_avg_time(1.day.ago)
|
2013-03-29 01:02:59 +08:00
|
|
|
|
|
|
|
# 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
|
2014-02-27 08:45:20 +08:00
|
|
|
ScoreCalculator.new.calculate(1.day.ago)
|
2013-12-24 07:50:36 +08:00
|
|
|
|
2014-03-01 03:33:52 +08:00
|
|
|
# Update the scores of topics
|
|
|
|
TopTopic.refresh!
|
|
|
|
|
2013-11-11 07:52:44 +08:00
|
|
|
# Automatically close stuff that we missed
|
|
|
|
Topic.auto_close
|
2014-05-28 10:30:43 +08:00
|
|
|
|
2014-05-28 14:54:21 +08:00
|
|
|
# Forces rebake of old posts where needed, as long as no system avatars need updating
|
2014-05-30 12:17:35 +08:00
|
|
|
unless UserAvatar.where("last_gravatar_download_attempt IS NULL").limit(1).first
|
2014-05-28 14:54:21 +08:00
|
|
|
Post.rebake_old(250)
|
|
|
|
end
|
2013-03-29 01:02:59 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|