Move clean up of unconfirmed users to sidekiq-scheduler (#4336)
* Move clean up of unconfirmed users to sidekiq-scheduler * mastodon:daily is now deprecatedgh/stable
parent
2374d63536
commit
467456f7a1
|
@ -0,0 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
require 'sidekiq-scheduler'
|
||||||
|
|
||||||
|
class Scheduler::UserCleanupScheduler
|
||||||
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
def perform
|
||||||
|
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
|
||||||
|
User.where(id: batch.map(&:id)).delete_all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -18,3 +18,6 @@
|
||||||
doorkeeper_cleanup_scheduler:
|
doorkeeper_cleanup_scheduler:
|
||||||
cron: '1 1 * * 0'
|
cron: '1 1 * * 0'
|
||||||
class: Scheduler::DoorkeeperCleanupScheduler
|
class: Scheduler::DoorkeeperCleanupScheduler
|
||||||
|
user_cleanup_scheduler:
|
||||||
|
cron: '4 5 * * *'
|
||||||
|
class: Scheduler::UserCleanupScheduler
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
namespace :mastodon do
|
namespace :mastodon do
|
||||||
desc 'Execute daily tasks'
|
desc 'Execute daily tasks (deprecated)'
|
||||||
task :daily do
|
task :daily do
|
||||||
%w(
|
# No-op
|
||||||
mastodon:feeds:clear
|
# All of these tasks are now executed via sidekiq-scheduler
|
||||||
mastodon:media:clear
|
|
||||||
mastodon:users:clear
|
|
||||||
mastodon:push:refresh
|
|
||||||
).each do |task|
|
|
||||||
puts "Starting #{task} at #{Time.now.utc}"
|
|
||||||
Rake::Task[task].invoke
|
|
||||||
end
|
|
||||||
puts "Completed daily tasks at #{Time.now.utc}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Turn a user into an admin, identified by the USERNAME environment variable'
|
desc 'Turn a user into an admin, identified by the USERNAME environment variable'
|
||||||
|
@ -162,14 +154,10 @@ namespace :mastodon do
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :users do
|
namespace :users do
|
||||||
desc 'Clear out unconfirmed users'
|
desc 'Clear out unconfirmed users (deprecated)'
|
||||||
task clear: :environment do
|
task clear: :environment do
|
||||||
# Users that never confirmed e-mail never signed in, means they
|
# No-op
|
||||||
# only have a user record and an avatar record, with no files uploaded
|
# This task is now executed via sidekiq-scheduler
|
||||||
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
|
|
||||||
User.where(id: batch.map(&:id)).delete_all
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'List e-mails of all admin users'
|
desc 'List e-mails of all admin users'
|
||||||
|
|
Reference in New Issue