mastodon/app/workers/scheduler/notifications_cleanup_scheduler.rb
David Roetzel 634fc631b3
Add scheduled job to clean up old notficiations.
This is a first step to have something concrete to discuss.

Needs tuning and tests.
2024-08-01 13:59:21 +02:00

19 lines
397 B
Ruby

# frozen_string_literal: true
class Scheduler::NotificationsCleanupScheduler
include Sidekiq::Worker
include LowPriorityScheduler
TYPES_TO_CLEAN_UP = Notification::TYPES
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
def perform
return if under_load?
TYPES_TO_CLEAN_UP.each do |type|
NotificationsCleanupService.new.call(type)
end
end
end