Merge pull request #1000 from Retrospring/re-add-cleanup-rake-task

re-add removed remove_stale rake task
This commit is contained in:
Karina Kwiatek 2023-01-27 17:23:56 +01:00 committed by GitHub
commit 70207cc608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -51,6 +51,15 @@ namespace :justask do # rubocop:disable Metrics/BlockLength
user.remove_role :moderator user.remove_role :moderator
puts "#{user.screen_name} is no longer a moderator." puts "#{user.screen_name} is no longer a moderator."
end end
desc "Removes users whose accounts haven't been verified for over 3 months."
task remove_stale: :environment do
puts "Removing stale users…"
removed = User.where(confirmed_at: nil)
.where("confirmation_sent_at < ?", DateTime.now.utc - 3.months)
.destroy_all.count
puts "Removed #{removed} users"
end
end end
namespace :db do namespace :db do