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)
|
|
|
|
|
|
|
|
# Feature topics in categories
|
|
|
|
CategoryFeaturedTopic.feature_topics
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2013-11-11 10:52:44 +11:00
|
|
|
# Automatically close stuff that we missed
|
|
|
|
Topic.auto_close
|
2014-05-28 12:30:43 +10:00
|
|
|
|
2014-05-28 16:54:21 +10:00
|
|
|
# Forces rebake of old posts where needed, as long as no system avatars need updating
|
2014-05-30 14:17:35 +10:00
|
|
|
unless UserAvatar.where("last_gravatar_download_attempt IS NULL").limit(1).first
|
2014-07-17 13:22:46 -07:00
|
|
|
problems = Post.rebake_old(250)
|
|
|
|
problems.each do |hash|
|
|
|
|
Discourse.handle_exception(hash[:ex], error_context(args, "Rebaking post id #{hash[:post].id}", post_id: hash[:post].id))
|
|
|
|
end
|
2014-05-28 16:54:21 +10:00
|
|
|
end
|
2014-06-24 17:10:56 +10:00
|
|
|
|
2014-08-05 16:37:56 +10:00
|
|
|
# rebake out of date user profiles
|
|
|
|
problems = UserProfile.rebake_old(250)
|
|
|
|
problems.each do |hash|
|
|
|
|
user_id = hash[:profile].user_id
|
|
|
|
Discourse.handle_exception(hash[:ex], error_context(args, "Rebaking user id #{user_id}", user_id: user_id))
|
|
|
|
end
|
2013-03-28 13:02:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|