From e1b3ea122c88801eb99e9f10e3cb2c04f7030ece Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 6 May 2021 12:49:37 +0200 Subject: [PATCH] Update lib/tasks/deployment/20210429172327_rename_conservation_extension.rake Co-authored-by: Pierre de La Morinerie --- .../20210429172327_rename_conservation_extension.rake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/tasks/deployment/20210429172327_rename_conservation_extension.rake b/lib/tasks/deployment/20210429172327_rename_conservation_extension.rake index 070fbfeff..fe94738d1 100644 --- a/lib/tasks/deployment/20210429172327_rename_conservation_extension.rake +++ b/lib/tasks/deployment/20210429172327_rename_conservation_extension.rake @@ -10,10 +10,9 @@ namespace :after_party do dossier.update_column(:conservation_extension, dossier.en_construction_conservation_extension) end - dossiers = Dossier.where(conservation_extension: nil) - n = (dossiers.count / BATCH_SIZE).ceil + 1 - n.times do - dossiers.limit(BATCH_SIZE).update_all(conservation_extension: 0.days) + dossiers_without_conservation_extension = Dossier.where(conservation_extension: nil) + dossiers_without_conservation_extension.in_batches do |relation| + relation.update_all(conservation_extension: 0.days) end # Update task as completed. If you remove the line below, the task will