Merge pull request #1507 from betagouv/fix-1479-task

[Fix #1479] Task to clean invalid emails
This commit is contained in:
Mathieu Magnin 2018-03-05 09:56:25 +01:00 committed by GitHub
commit b74362b094
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,11 @@
namespace :'2018_02_28_clean_invalid_emails_accounts' do
task clean: :environment do
Gestionnaire.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id|
Gestionnaire.find_by(id: id, current_sign_in_at: nil).try(:destroy) # ensure account was never used
end
User.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id|
User.find_by(id: id, current_sign_in_at: nil).try(:destroy) # ensure account was never used
end
end
end