From 00d96882990c1536d94eca92206bbd336213a950 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 7 Jan 2022 18:19:17 +0100 Subject: [PATCH] Add Rake task for removing stale users --- Rakefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Rakefile b/Rakefile index b386660c..51594612 100644 --- a/Rakefile +++ b/Rakefile @@ -238,6 +238,15 @@ namespace :justask do 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 + desc "Fixes the notifications" task fix_notifications: :environment do format = '%t (%c/%C) [%b>%i] %e'