[#10951] Create a cron job to warn user with a old brouillon

This commit is contained in:
Mathieu Magnin 2024-11-19 12:51:40 +01:00
parent b77a5f4c6e
commit 38e9ca4979
No known key found for this signature in database
GPG key ID: 8DCAFC82D7BA654E
10 changed files with 221 additions and 1 deletions

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
class Cron::NotifyOldBrouillonDossiersSoonDeletedJob < Cron::CronJob
self.schedule_expression = "every day at 9:00"
def perform
Dossier
.state_brouillon
.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
dossier.update_column(:notified_soon_deleted_sent_at, Time.zone.now)
end
end
end