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:
Bianca Nenciu
2025-02-11 10:26:45 +02:00
committed by GitHub
parent 43e8172ebc
commit 87f8845940
8 changed files with 77 additions and 19 deletions

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View File

@ -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