[#10951] fixes after review

This commit is contained in:
Mathieu Magnin 2024-11-28 10:56:24 +01:00
parent 5ab0899a49
commit 39baa5aae1
No known key found for this signature in database
GPG key ID: 8DCAFC82D7BA654E
3 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -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?