add task to remove dol orphan

This commit is contained in:
simon lehericey 2023-10-11 17:28:58 +02:00
parent af96551580
commit a37638283a

View file

@ -0,0 +1,19 @@
namespace :after_party do
desc 'Deployment task: remove_orphan_dossier_operation_logs'
task remove_orphan_dossier_operation_logs: :environment do
puts "Running deploy task 'remove_orphan_dossier_operation_logs'"
orphan_dols = DossierOperationLog.where.missing(:dossier).limit(400_000)
batch_size = 1_000
progress = ProgressReport.new(orphan_dols.count)
orphan_dols.in_batches(of: batch_size) do |b|
b.destroy_all
progress.inc(batch_size)
end
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end