feat(User): add maintenance task to backfill email_verified_at

This commit is contained in:
simon lehericey 2024-05-27 11:37:09 +02:00
parent 1cf9535bea
commit 555df3a6d8
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
# We are going to confirm the various email addresses of the users in the system.
# Individual model (mandant) needs their email_verified_at attribute to be set in order to receive emails.
# This task sets the email_verified_at attribute to the current time for all the individual to be backward compatible
# See https://github.com/demarches-simplifiees/demarches-simplifiees.fr/issues/10450
module Maintenance
class PrefillIndividualEmailVerifiedAtTask < MaintenanceTasks::Task
def collection
Individual.in_batches
end
def process(batch_of_individuals)
batch_of_individuals.update_all(email_verified_at: Time.zone.now)
end
end
end

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
# We are going to confirm the various email addresses of the users in the system.
# User model needs their email_verified_at attribute to be set in order to receive emails.
# This task sets the email_verified_at attribute to the current time for all users to be backward compatible
# See https://github.com/demarches-simplifiees/demarches-simplifiees.fr/issues/10450
module Maintenance
class PrefillUserEmailVerifiedAtTask < MaintenanceTasks::Task
def collection
User.in_batches
end
def process(batch_of_users)
batch_of_users.update_all(email_verified_at: Time.zone.now)
end
end
end