1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

task to delete inactive users

This commit is contained in:
Sylvain 2019-06-12 16:06:30 +02:00
parent d0cd5a90d2
commit 4edab0c53a
2 changed files with 16 additions and 1 deletions

View File

@ -12,8 +12,9 @@
- Refactored some Ruby code to match style guide
- [TODO DEPLOY] `rake fablab:fix:users_group_ids`
- [TODO DEPLOY] `rake db:migrate`
- [TODO DEPLOY] `rake fablab:setup:migrate_pdf_invoices_folders`
- [TODO DEPLOY] `rake db:seed`
- [TODO DEPLOY] `rake fablab:setup:migrate_pdf_invoices_folders`
- [TODO DEPLOY] `rake fablab:maintenance:delete_inactive_users` (will prompt for confirmation)
## v3.1.2 2019 May 27

View File

@ -50,5 +50,19 @@ namespace :fablab do
require 'checksum'
puts Checksum.code
end
desc 'delete users with accounts marked with is_active=false'
task delete_inactive_users: :environment do
count = User.where(is_active: false).count
if count.positive?
print "WARNING: You are about to delete #{count} users. Are you sure? (y/n) "
confirm = STDIN.gets.chomp
next unless confirm == 'y'
User.where(is_active: false).map(&:destroy!)
else
puts 'No inactive users to delete'
end
end
end
end