amelioration(UserDeletionService): on ne supprime pas 800k utilisateurs en une passe

This commit is contained in:
Martin 2023-11-07 10:51:55 +01:00 committed by mfo
parent 3186b0aa68
commit afc7df9c7c

View file

@ -53,14 +53,15 @@ class Expired::UsersDeletionService < Expired::MailRateLimiter
def to_notify_only(users)
users.where(inactive_close_to_expiration_notice_sent_at: nil)
.limit(limit)
.limit(daily_limit) # ensure to not send too much email
end
def to_delete_only(users)
users.where.not(inactive_close_to_expiration_notice_sent_at: Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks.ago..)
.limit(daily_limit) # event if we do not send email, avoid to destroy 800k user in one batch
end
def limit
def daily_limit
(ENV['EXPIRE_USER_DELETION_JOB_LIMIT'] || 10_000).to_i
end
end