Skip to content

Commit

Permalink
Ajoute une tache rake pour importer les identifiants pro-connect
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneCharignon committed Sep 25, 2024
1 parent cc4b18a commit de55e49
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/tasks/importe.rake
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,21 @@ namespace :importe do
Choix.find(id_nom_technique[0]).update(nom_technique: id_nom_technique[1])
end
end

desc 'Importe les id_pro_connect'
task id_pro_connect: :environment do
nb_ligne = 0
nb_importe = 0
CSV.parse($stdin, headers: true, header_converters: :symbol).each do |row|
nb_ligne += 1
ligne = row.to_hash
compte = Compte.find_by id_inclusion_connect: ligne[:id_inclusion_connect]
next if compte.blank?

RakeLogger.logger.info "Importe : #{ligne[:id_inclusion_connect]},#{ligne[:id_pro_connect]}"
compte.update!(id_pro_connect: ligne[:id_pro_connect])
nb_importe += 1
end
RakeLogger.logger.info "Importés : #{nb_importe} / #{nb_ligne}"
end
end

0 comments on commit de55e49

Please sign in to comment.