Update lib/tasks/deployment/20210429172327_rename_conservation_extension.rake

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
This commit is contained in:
Paul Chavard 2021-05-06 12:49:37 +02:00
parent 1e0d6ea28f
commit e1b3ea122c

View file

@ -10,10 +10,9 @@ namespace :after_party do
dossier.update_column(:conservation_extension, dossier.en_construction_conservation_extension) dossier.update_column(:conservation_extension, dossier.en_construction_conservation_extension)
end end
dossiers = Dossier.where(conservation_extension: nil) dossiers_without_conservation_extension = Dossier.where(conservation_extension: nil)
n = (dossiers.count / BATCH_SIZE).ceil + 1 dossiers_without_conservation_extension.in_batches do |relation|
n.times do relation.update_all(conservation_extension: 0.days)
dossiers.limit(BATCH_SIZE).update_all(conservation_extension: 0.days)
end end
# Update task as completed. If you remove the line below, the task will # Update task as completed. If you remove the line below, the task will