[#10951] Create a cron job to warn user with a old brouillon
This commit is contained in:
parent
b77a5f4c6e
commit
38e9ca4979
10 changed files with 221 additions and 1 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue