From 4eaa6ae049f414743503452611018a77093c53e2 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 21 Dec 2022 10:12:33 +0100 Subject: [PATCH] fix(dossier): schedule a rebase to all pending dossiers --- ...0151_schedule_rebase_for_all_dossiers.rake | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/tasks/deployment/20221221090151_schedule_rebase_for_all_dossiers.rake diff --git a/lib/tasks/deployment/20221221090151_schedule_rebase_for_all_dossiers.rake b/lib/tasks/deployment/20221221090151_schedule_rebase_for_all_dossiers.rake new file mode 100644 index 000000000..0cd16cc12 --- /dev/null +++ b/lib/tasks/deployment/20221221090151_schedule_rebase_for_all_dossiers.rake @@ -0,0 +1,24 @@ +namespace :after_party do + desc 'Deployment task: schedule_rebase_for_all_dossiers' + task schedule_rebase_for_all_dossiers: :environment do + puts "Running deploy task 'schedule_rebase_for_all_dossiers'" + + dossiers = Dossier.joins(:procedure) + .state_not_termine + .state_not_brouillon + .where('revision_id != procedures.published_revision_id') + + progress = ProgressReport.new(dossiers.count) + + dossiers.find_each do |dossier| + dossier.rebase_later + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end