From b39cd48d6f81a200081fb732e559fd3d5444825f Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 8 Mar 2018 11:36:17 +0100 Subject: [PATCH 1/3] =?UTF-8?q?[Fix=20#1545]=20Rake=20task=20to=20send=20a?= =?UTF-8?q?ccus=C3=A9s=20de=20r=C3=A9ception=20that=20were=20missed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (because of #1510) --- ...18_03_08_send_missed_accuse_reception.rake | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/tasks/2018_03_08_send_missed_accuse_reception.rake diff --git a/lib/tasks/2018_03_08_send_missed_accuse_reception.rake b/lib/tasks/2018_03_08_send_missed_accuse_reception.rake new file mode 100644 index 000000000..ae29fe2a1 --- /dev/null +++ b/lib/tasks/2018_03_08_send_missed_accuse_reception.rake @@ -0,0 +1,22 @@ +namespace :'2018_03_08_send_missing_accuse_reception' do + task send: :environment do + # Send accusés de réception that were missed because of #1510 + # + # The bug was introduced in production with the 2018-03-01-01 release + # and fixed with the 2018-03-05-03 release. + # + # `bug_date` and `fix_date` were determined empirically by looking at the release times, + # and checking for dossiers with a missing accusé de réception. + + bug_date = DateTime.new(2018, 3, 1, 9, 15) + fix_date = DateTime.new(2018, 3, 5, 18, 35) + + # Only send the accusé for dossiers that are still en construction. + # For dossiers that have moved on, other mails have been sent since, and a late + # accusé de réception would add more confusion than it’s worth + problem_dossiers = Dossier.state_en_construction.where(en_construction_at: bug_date..fix_date) + problem_dossiers.find_each do |dossier| + NotificationMailer.send_notification(dossier, dossier.procedure.initiated_mail_template).deliver_now! + end + end +end From 1b889a410018da01630e7b3f7d3c01eacf637533 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Fri, 9 Mar 2018 17:18:53 +0100 Subject: [PATCH 2/3] [#1545] Also notify dossiers that are not en construction This forces us to have more precise bug and fix times --- lib/tasks/2018_03_08_send_missed_accuse_reception.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/2018_03_08_send_missed_accuse_reception.rake b/lib/tasks/2018_03_08_send_missed_accuse_reception.rake index ae29fe2a1..c52526af9 100644 --- a/lib/tasks/2018_03_08_send_missed_accuse_reception.rake +++ b/lib/tasks/2018_03_08_send_missed_accuse_reception.rake @@ -8,13 +8,13 @@ namespace :'2018_03_08_send_missing_accuse_reception' do # `bug_date` and `fix_date` were determined empirically by looking at the release times, # and checking for dossiers with a missing accusé de réception. - bug_date = DateTime.new(2018, 3, 1, 9, 15) - fix_date = DateTime.new(2018, 3, 5, 18, 35) + bug_date = DateTime.new(2018, 3, 1, 9, 50) + fix_date = DateTime.new(2018, 3, 5, 18, 40) # Only send the accusé for dossiers that are still en construction. # For dossiers that have moved on, other mails have been sent since, and a late # accusé de réception would add more confusion than it’s worth - problem_dossiers = Dossier.state_en_construction.where(en_construction_at: bug_date..fix_date) + problem_dossiers = Dossier.where(en_construction_at: bug_date..fix_date) problem_dossiers.find_each do |dossier| NotificationMailer.send_notification(dossier, dossier.procedure.initiated_mail_template).deliver_now! end From dd1026100929c2ca32a813064313c1451fef47d0 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Fri, 9 Mar 2018 17:58:15 +0100 Subject: [PATCH 3/3] [Fix #1545] Add explanatory message --- lib/tasks/2018_03_08_send_missed_accuse_reception.rake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tasks/2018_03_08_send_missed_accuse_reception.rake b/lib/tasks/2018_03_08_send_missed_accuse_reception.rake index c52526af9..d01343e15 100644 --- a/lib/tasks/2018_03_08_send_missed_accuse_reception.rake +++ b/lib/tasks/2018_03_08_send_missed_accuse_reception.rake @@ -16,7 +16,11 @@ namespace :'2018_03_08_send_missing_accuse_reception' do # accusé de réception would add more confusion than it’s worth problem_dossiers = Dossier.where(en_construction_at: bug_date..fix_date) problem_dossiers.find_each do |dossier| - NotificationMailer.send_notification(dossier, dossier.procedure.initiated_mail_template).deliver_now! + template = dossier.procedure.initiated_mail_template + date_depot = dossier.en_construction_at.in_time_zone("Paris").strftime('%d/%m/%Y à %H:%M') + body_prefix = "

Suite à une difficulté technique, veuillez recevoir par la présente l’accusé de réception pour votre dossier déposé le #{date_depot}.
L’équipe demarches-simplifiees.fr vous présente ses excuses pour la gène occasionnée.


\n" + template.body = body_prefix + template.body + NotificationMailer.send_notification(dossier, template).deliver_now! end end end