task(routing): add a new task to reset forced_groupe_instructeur value
This commit is contained in:
parent
21b6c68761
commit
3349d72912
1 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue