Skip to content

Commit

Permalink
Ajoute une tache rake pour importer les SIRETs des structures des con…
Browse files Browse the repository at this point in the history
…seillers InclusionConnect
  • Loading branch information
etienneCharignon committed Sep 25, 2024
1 parent de55e49 commit d6e1fea
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/tasks/importe.rake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ namespace :importe do
end
end

desc 'Importe les SIRETs des structures des conseillers connus'
task siret: :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? || compte.structure.blank? || compte.structure.siret.present?

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

choix = [
%w[2c178015-a7c1-4ff8-a344-8553a61e754a bienvenue_pas_facile],
%w[e9ac38e1-41d6-4248-bb17-ffdef2416868 bienvenue_plutot_pas_facile],
Expand Down

0 comments on commit d6e1fea

Please sign in to comment.