mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 07:23:43 +01:00
Keep scheduler jobs unique until they're done (#8287)
This commit is contained in:
parent
59c68c1a74
commit
91c929a42c
9 changed files with 18 additions and 0 deletions
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::BackupCleanupScheduler
|
class Scheduler::BackupCleanupScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
old_backups.find_each(&:destroy!)
|
old_backups.find_each(&:destroy!)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::DoorkeeperCleanupScheduler
|
class Scheduler::DoorkeeperCleanupScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
Doorkeeper::AccessToken.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all
|
Doorkeeper::AccessToken.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all
|
||||||
Doorkeeper::AccessGrant.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all
|
Doorkeeper::AccessGrant.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::EmailScheduler
|
class Scheduler::EmailScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
eligible_users.find_each do |user|
|
eligible_users.find_each do |user|
|
||||||
next unless user.allows_digest_emails?
|
next unless user.allows_digest_emails?
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::FeedCleanupScheduler
|
class Scheduler::FeedCleanupScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
clean_home_feeds!
|
clean_home_feeds!
|
||||||
clean_list_feeds!
|
clean_list_feeds!
|
||||||
|
|
|
@ -5,6 +5,8 @@ class Scheduler::IpCleanupScheduler
|
||||||
|
|
||||||
RETENTION_PERIOD = 1.year
|
RETENTION_PERIOD = 1.year
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
time_ago = RETENTION_PERIOD.ago
|
time_ago = RETENTION_PERIOD.ago
|
||||||
SessionActivation.where('updated_at < ?', time_ago).destroy_all
|
SessionActivation.where('updated_at < ?', time_ago).destroy_all
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::MediaCleanupScheduler
|
class Scheduler::MediaCleanupScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
unattached_media.find_each(&:destroy)
|
unattached_media.find_each(&:destroy)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::SubscriptionsCleanupScheduler
|
class Scheduler::SubscriptionsCleanupScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
Subscription.expired.in_batches.delete_all
|
Subscription.expired.in_batches.delete_all
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::SubscriptionsScheduler
|
class Scheduler::SubscriptionsScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
Pubsubhubbub::SubscribeWorker.push_bulk(expiring_accounts.pluck(:id))
|
Pubsubhubbub::SubscribeWorker.push_bulk(expiring_accounts.pluck(:id))
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class Scheduler::UserCleanupScheduler
|
class Scheduler::UserCleanupScheduler
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options unique: :until_executed
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
User.where('confirmed_at is NULL AND confirmation_sent_at <= ?', 2.days.ago).find_in_batches do |batch|
|
User.where('confirmed_at is NULL AND confirmation_sent_at <= ?', 2.days.ago).find_in_batches do |batch|
|
||||||
Account.where(id: batch.map(&:account_id)).delete_all
|
Account.where(id: batch.map(&:account_id)).delete_all
|
||||||
|
|
Loading…
Reference in a new issue