add task to remove dol orphan
This commit is contained in:
parent
af96551580
commit
a37638283a
1 changed files with 19 additions and 0 deletions
|
@ -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
|
Loading…
Reference in a new issue