From 704cd60e0437aeaa92b64fa5ca6fb79ce57014cb Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 29 May 2024 15:56:49 +0200 Subject: [PATCH] chore(task): run commune code fix on all champs of a procedure --- .../maintenance/backfill_commune_code_from_name_task.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/tasks/maintenance/backfill_commune_code_from_name_task.rb b/app/tasks/maintenance/backfill_commune_code_from_name_task.rb index 8c50b075e..922c3a377 100644 --- a/app/tasks/maintenance/backfill_commune_code_from_name_task.rb +++ b/app/tasks/maintenance/backfill_commune_code_from_name_task.rb @@ -2,11 +2,12 @@ module Maintenance class BackfillCommuneCodeFromNameTask < MaintenanceTasks::Task - attribute :champ_ids, :string - validates :champ_ids, presence: true + attribute :procedure_id, :string + validates :procedure_id, presence: true def collection - Champ.where(id: champ_ids.split(',').map(&:strip).map(&:to_i)) + procedure = Procedure.find(procedure_id.strip.to_i) + Champs::CommuneChamp.where(dossier_id: procedure.dossiers.not_brouillon) end def process(champ)