demarches-normaliennes/lib/tasks/falsify_opendata_procedures.rake
Christophe Robillard 6851a9ee52 falsify opendata flag for some procedures
`procedures:falsify_opendata_procedures` rake task allows to falsify
opndata flag for procedures listed in csv file given in input (with only
one column : id column)
2023-03-01 11:47:11 +01:00

23 lines
622 B
Ruby

require Rails.root.join("lib", "tasks", "task_helper")
namespace :procedures do
desc <<~EOD
falsify opendata flag for some procedures
rails procedures:falsify_opendata_procedures\[csv_path\]
EOD
task :falsify_opendata_procedures, [:csv] => :environment do |_t, args|
csv = args[:csv]
lines = CSV.readlines(csv, headers: true)
rake_puts "Passage du flag opendata à false pour certaines procédures en cours..."
errors =
FalsifyOpendataService.call(lines)
if errors.present?
errors.each { |error| rake_puts error }
end
rake_puts "Mise à jour terminée"
end
end