From 39baa5aae1d8c544596acb319eb9a311739a3d43 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 28 Nov 2024 10:56:24 +0100 Subject: [PATCH] [#10951] fixes after review --- .../cron/notify_old_brouillon_dossiers_soon_deleted_job.rb | 4 ++-- app/jobs/cron/purge_old_brouillon_dossiers_job.rb | 2 +- app/models/dossier.rb | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/jobs/cron/notify_old_brouillon_dossiers_soon_deleted_job.rb b/app/jobs/cron/notify_old_brouillon_dossiers_soon_deleted_job.rb index 680d56b3d..95e54617c 100644 --- a/app/jobs/cron/notify_old_brouillon_dossiers_soon_deleted_job.rb +++ b/app/jobs/cron/notify_old_brouillon_dossiers_soon_deleted_job.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Cron::NotifyOldBrouillonDossiersSoonDeletedJob < Cron::CronJob - self.schedule_expression = "every day at 9:00" + self.schedule_expression = "every day at 6:00" def perform Dossier @@ -9,7 +9,7 @@ class Cron::NotifyOldBrouillonDossiersSoonDeletedJob < Cron::CronJob .where(updated_at: ..3.months.ago) .where("notified_soon_deleted_sent_at IS NULL OR notified_soon_deleted_sent_at < updated_at") .find_each do |dossier| - DossierMailer.notify_old_brouillon_soon_deleted(dossier).deliver_later + DossierMailer.notify_old_brouillon_soon_deleted(dossier).deliver_later(wait: rand(0..3.hours)) dossier.update_column(:notified_soon_deleted_sent_at, Time.zone.now) end end diff --git a/app/jobs/cron/purge_old_brouillon_dossiers_job.rb b/app/jobs/cron/purge_old_brouillon_dossiers_job.rb index 40aa4207f..147b16a29 100644 --- a/app/jobs/cron/purge_old_brouillon_dossiers_job.rb +++ b/app/jobs/cron/purge_old_brouillon_dossiers_job.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Cron::PurgeOldBrouillonDossiersJob < Cron::CronJob - self.schedule_expression = "every day at 08:30" + self.schedule_expression = "every day at 5:30" def perform Dossier diff --git a/app/models/dossier.rb b/app/models/dossier.rb index c6edd192a..ae9d12e57 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -567,7 +567,10 @@ class Dossier < ApplicationRecord end def can_be_deleted_by_automatic?(reason) - reason == :expired && !en_instruction? || reason == :not_modified_for_a_long_time && brouillon? + return true if reason == :expired && !en_instruction? + return true if reason == :not_modified_for_a_long_time && brouillon? + + false end def can_terminer_automatiquement_by_sva_svr?