task(dossiers): delete MAE procedures expired dossiers
This commit is contained in:
parent
14d3956419
commit
e4317e8c7e
1 changed files with 16 additions and 0 deletions
16
lib/tasks/ds/destroy_expired_dossiers_mae.rake
Normal file
16
lib/tasks/ds/destroy_expired_dossiers_mae.rake
Normal file
|
@ -0,0 +1,16 @@
|
|||
namespace :ds do
|
||||
desc 'DS task: destroy_expired_dossiers_mae'
|
||||
task destroy_expired_dossiers_mae: :environment do
|
||||
dossiers = Dossier.state_termine
|
||||
.where("termine_close_to_expiration_notice_sent_at + INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: '30 days' })
|
||||
.joins(:groupe_instructeur)
|
||||
.where(groupe_instructeur: { procedure_id: [47787, 47844, 47478, 47865] })
|
||||
progress = ProgressReport.new(dossiers.count)
|
||||
|
||||
dossiers.find_each do |dossier|
|
||||
dossier.expired_keep_track_and_destroy!
|
||||
progress.inc
|
||||
end
|
||||
progress.finish
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue