mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
DEV: Split weekly job into multiple smaller jobs (#31260)
The weekly job can take more than 2 hours to run on larger sites. It is ideal for the jobs to be as small as possible and this is what this commit attempts.
This commit is contained in:
11
app/jobs/scheduled/calculate_scores.rb
Normal file
11
app/jobs/scheduled/calculate_scores.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class CalculateScores < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
ScoreCalculator.new.calculate
|
||||
end
|
||||
end
|
||||
end
|
11
app/jobs/scheduled/clean_up_bookmarks.rb
Normal file
11
app/jobs/scheduled/clean_up_bookmarks.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class CleanUpBookmarks < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
Bookmark.cleanup!
|
||||
end
|
||||
end
|
||||
end
|
11
app/jobs/scheduled/clean_up_drafts.rb
Normal file
11
app/jobs/scheduled/clean_up_drafts.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class CleanUpDrafts < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
Draft.cleanup!
|
||||
end
|
||||
end
|
||||
end
|
11
app/jobs/scheduled/clean_up_user_auth_tokens.rb
Normal file
11
app/jobs/scheduled/clean_up_user_auth_tokens.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class CleanUpUserAuthTokens < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
UserAuthToken.cleanup!
|
||||
end
|
||||
end
|
||||
end
|
11
app/jobs/scheduled/delete_rejected_emails.rb
Normal file
11
app/jobs/scheduled/delete_rejected_emails.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class DeleteRejectedEmails < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
Email::Cleaner.delete_rejected!
|
||||
end
|
||||
end
|
||||
end
|
11
app/jobs/scheduled/purge_old_mini_scheduler_stat.rb
Normal file
11
app/jobs/scheduled/purge_old_mini_scheduler_stat.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class PurgeOldMiniSchedulerStat < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
MiniScheduler::Stat.purge_old
|
||||
end
|
||||
end
|
||||
end
|
11
app/jobs/scheduled/purge_old_notifications.rb
Normal file
11
app/jobs/scheduled/purge_old_notifications.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class PurgeOldNotifications < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
Notification.purge_old!
|
||||
end
|
||||
end
|
||||
end
|
@ -1,19 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
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 Weekly < ::Jobs::Scheduled
|
||||
every 1.week
|
||||
|
||||
def execute(args)
|
||||
ScoreCalculator.new.calculate
|
||||
MiniScheduler::Stat.purge_old
|
||||
Draft.cleanup!
|
||||
UserAuthToken.cleanup!
|
||||
Email::Cleaner.delete_rejected!
|
||||
Notification.purge_old!
|
||||
Bookmark.cleanup!
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user