2020-11-13 14:34:53 +01:00
|
|
|
class Cron::DiscardedDossiersDeletionJob < Cron::CronJob
|
2020-04-01 15:26:46 +02:00
|
|
|
self.schedule_expression = "every day at 2 am"
|
2020-03-19 13:11:45 +01:00
|
|
|
|
|
|
|
def perform(*args)
|
2020-11-26 15:13:32 +01:00
|
|
|
DossierOperationLog.where(dossier: Dossier.discarded_en_construction_expired)
|
|
|
|
.where.not(operation: DossierOperationLog.operations.fetch(:supprimer))
|
|
|
|
.destroy_all
|
|
|
|
DossierOperationLog.where(dossier: Dossier.discarded_termine_expired)
|
|
|
|
.where.not(operation: DossierOperationLog.operations.fetch(:supprimer))
|
|
|
|
.destroy_all
|
|
|
|
|
2020-03-19 13:11:45 +01:00
|
|
|
Dossier.discarded_brouillon_expired.destroy_all
|
|
|
|
Dossier.discarded_en_construction_expired.destroy_all
|
2020-11-26 15:13:32 +01:00
|
|
|
Dossier.discarded_termine_expired.destroy_all
|
2020-03-19 13:11:45 +01:00
|
|
|
end
|
|
|
|
end
|