tech(refactor): mutualise la duree de rentention apres notification entre dossier/user
This commit is contained in:
parent
aecc41490b
commit
c9d470d9ec
|
@ -69,7 +69,7 @@ class UserMailer < ApplicationMailer
|
|||
|
||||
def notify_inactive_close_to_deletion(user)
|
||||
@user = user
|
||||
@subject = "Votre compte sera supprimé dans #{Expired::UsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK} semaines"
|
||||
@subject = "Votre compte sera supprimé dans #{Expired::REMAINING_WEEKS_BEFORE_EXPIRATION} semaines"
|
||||
|
||||
mail(to: user.email, subject: @subject)
|
||||
end
|
||||
|
|
|
@ -25,8 +25,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
REMAINING_DAYS_BEFORE_CLOSING = 2
|
||||
INTERVAL_BEFORE_CLOSING = "#{REMAINING_DAYS_BEFORE_CLOSING} days"
|
||||
REMAINING_WEEKS_BEFORE_EXPIRATION = 2
|
||||
INTERVAL_BEFORE_EXPIRATION = "#{REMAINING_WEEKS_BEFORE_EXPIRATION} weeks"
|
||||
INTERVAL_BEFORE_EXPIRATION = "#{Expired::REMAINING_WEEKS_BEFORE_EXPIRATION} weeks"
|
||||
MONTHS_AFTER_EXPIRATION = 1
|
||||
DAYS_AFTER_EXPIRATION = 5
|
||||
INTERVAL_EXPIRATION = "#{MONTHS_AFTER_EXPIRATION} month #{DAYS_AFTER_EXPIRATION} days"
|
||||
|
@ -625,7 +624,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def expiration_notification_date
|
||||
expiration_date_with_extension - REMAINING_WEEKS_BEFORE_EXPIRATION.weeks
|
||||
expiration_date_with_extension - Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks
|
||||
end
|
||||
|
||||
def close_to_expiration?
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
module Expired
|
||||
REMAINING_WEEKS_BEFORE_EXPIRATION = 2
|
||||
|
||||
def self.schedule_at(caller)
|
||||
case caller.name
|
||||
when 'Cron::ExpiredPrefilledDossiersDeletionJob'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
class Expired::UsersDeletionService < Expired::MailRateLimiter
|
||||
RETENTION_AFTER_NOTICE_IN_WEEK = 2
|
||||
EXPIRABLE_AFTER_IN_YEAR = 2
|
||||
|
||||
def process_expired
|
||||
|
@ -60,7 +59,7 @@ class Expired::UsersDeletionService < Expired::MailRateLimiter
|
|||
end
|
||||
|
||||
def to_delete_only(users)
|
||||
users.where.not(inactive_close_to_expiration_notice_sent_at: RETENTION_AFTER_NOTICE_IN_WEEK.weeks.ago..)
|
||||
users.where.not(inactive_close_to_expiration_notice_sent_at: Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks.ago..)
|
||||
end
|
||||
|
||||
def limit
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
%strong= t('.account_active', count: @deleted_dossiers.size)
|
||||
|
||||
- if @state == Dossier.states.fetch(:en_construction)
|
||||
%p= t('.footer_en_construction', count: @deleted_dossiers.size)
|
||||
%p= t('.footer_en_construction', count: @deleted_dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks))
|
||||
|
||||
= render partial: "layouts/mailers/signature"
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
%p
|
||||
- if @state == Dossier.states.fetch(:en_construction)
|
||||
= sanitize(t('.footer_en_construction', count: @dossiers.size))
|
||||
= sanitize(t('.footer_en_construction', count: @dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks)))
|
||||
- else
|
||||
= sanitize(t('.footer_termine', count: @dossiers.size))
|
||||
= sanitize(t('.footer_termine', count: @dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks)))
|
||||
|
||||
= render partial: "layouts/mailers/signature"
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
%p
|
||||
- if @state == Dossier.states.fetch(:en_construction)
|
||||
= sanitize(t('.footer_en_construction', count: @dossiers.size))
|
||||
= sanitize(t('.footer_en_construction', count: @dossiers.size, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks)))
|
||||
- else
|
||||
= sanitize(t('.footer_termine', count: @dossiers.size, dossiers_url: dossiers_url))
|
||||
= sanitize(t('.footer_termine', count: @dossiers.size, dossiers_url: dossiers_url, remaining_weeks_before_expiration: distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks)))
|
||||
|
||||
= render partial: "layouts/mailers/signature"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
Cela fait plus de deux ans que vous ne vous êtes pas connecté à #{APPLICATION_NAME}.
|
||||
%br
|
||||
Dans le respect du RGPD, nous allons
|
||||
%strong supprimer votre compte d'ici #{distance_of_time_in_words(ExpiredUsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK.weeks)}.
|
||||
%strong supprimer votre compte d'ici #{distance_of_time_in_words(Expired::REMAINING_WEEKS_BEFORE_EXPIRATION.weeks)}.
|
||||
|
||||
%p
|
||||
%strong Ne vous en faites pas,
|
||||
|
|
|
@ -14,8 +14,8 @@ fr:
|
|||
one: "Le dossier suivant dont le traitement est terminé sera bientôt automatiquement supprimé :"
|
||||
other: "Les dossiers suivants dont le traitement est terminé seront bientôt automatiquement supprimés :"
|
||||
footer_en_construction:
|
||||
one: "Vous avez <b>deux semaines</b> pour commencer l’instruction du dossier."
|
||||
other: "Vous avez <b>deux semaines</b> pour commencer l’instruction des dossiers."
|
||||
one: "Vous avez <b>%{remaining_weeks_before_expiration}</b> pour commencer l’instruction du dossier."
|
||||
other: "Vous avez <b>%{remaining_weeks_before_expiration}</b> pour commencer l’instruction des dossiers."
|
||||
footer_termine:
|
||||
one: "Vous avez <b>deux semaines</b> pour archiver le dossier."
|
||||
other: "Vous avez <b>deux semaines</b> pour archiver les dossiers."
|
||||
one: "Vous avez <b>%{remaining_weeks_before_expiration}</b> pour archiver le dossier."
|
||||
other: "Vous avez <b>%{remaining_weeks_before_expiration}</b> pour archiver les dossiers."
|
||||
|
|
|
@ -152,7 +152,7 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it { expect(subject.body).to include("N° #{dossier.id} ") }
|
||||
it { expect(subject.body).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include("PDF") }
|
||||
it { expect(subject.body).to include("Vous avez <b>deux semaines</b> pour commencer l’instruction du dossier.") }
|
||||
it { expect(subject.body).to include("Vous avez <b>14 jours</b> pour commencer l’instruction du dossier.") }
|
||||
end
|
||||
|
||||
describe 'termine' do
|
||||
|
|
|
@ -2,8 +2,8 @@ describe Expired::UsersDeletionService do
|
|||
let(:last_signed_in_not_expired) { (Expired::UsersDeletionService::EXPIRABLE_AFTER_IN_YEAR - 1).years.ago }
|
||||
let(:last_signed_in_expired) { (Expired::UsersDeletionService::EXPIRABLE_AFTER_IN_YEAR + 1).years.ago }
|
||||
let(:before_close_to_expiration) { nil }
|
||||
let(:notified_close_to_expiration) { (Expired::UsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK - 1).weeks.ago }
|
||||
let(:due_close_to_expiration) { (Expired::UsersDeletionService::RETENTION_AFTER_NOTICE_IN_WEEK + 1).weeks.ago }
|
||||
let(:notified_close_to_expiration) { (Expired::REMAINING_WEEKS_BEFORE_EXPIRATION - 1).weeks.ago }
|
||||
let(:due_close_to_expiration) { (Expired::REMAINING_WEEKS_BEFORE_EXPIRATION + 1).weeks.ago }
|
||||
let(:mail_double) do
|
||||
dbl = double()
|
||||
expect(dbl).to receive(:deliver_later).with(wait: 0)
|
||||
|
|
Loading…
Reference in a new issue