task(routing): add a new task to reset forced_groupe_instructeur value

This commit is contained in:
Eric Leroy-Terquem 2024-04-12 10:37:26 +02:00
parent 21b6c68761
commit 3349d72912
No known key found for this signature in database
GPG key ID: ECE60B4C1FA2ABB3

View file

@ -24,4 +24,25 @@ namespace :re_routing_dossiers do
end
progress.finish
end
desc <<~EOD
Given an procedure id in argument, reset value of forced_groupe_instructeur to false for all dossiers en_construction.
ex: rails re_routing_dossiers:reset_forced_groupe_instructeur\[85869\]
EOD
task :reset_forced_groupe_instructeur, [:procedure_id] => :environment do |_t, args|
procedure = Procedure.find_by(id: args[:procedure_id])
dossiers = procedure.dossiers.state_en_construction
progress = ProgressReport.new(dossiers.count)
dossiers.each do |dossier|
if dossier.update(forced_groupe_instructeur: false)
rake_puts "Dossier #{dossier.id} updated with forced_groupe_instructeur to false"
progress.inc
end
end
progress.finish
end
end