From c93e893cc3f5de1cc93ffb709b404da476a2411a Mon Sep 17 00:00:00 2001 From: Daniel Illi Date: Fri, 6 Dec 2024 18:22:10 +0100 Subject: [PATCH] SacImports: WSO2 log uuid -> hitobito id mapping --- app/domain/sac_imports/csv_source/wso2.rb | 2 +- app/domain/sac_imports/wso2/person_entry.rb | 2 +- app/domain/sac_imports/wso2_people_importer.rb | 13 +++++++++++++ spec/domain/sac_imports/wso2/person_entry_spec.rb | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/domain/sac_imports/csv_source/wso2.rb b/app/domain/sac_imports/csv_source/wso2.rb index a0b12ef39..a0a57f665 100644 --- a/app/domain/sac_imports/csv_source/wso2.rb +++ b/app/domain/sac_imports/csv_source/wso2.rb @@ -10,7 +10,7 @@ class SacImports::CsvSource # they must match the order of the columns in the CSV files Wso2 = Data.define( :um_id, # "UM_ID", - :_um_user_name, # "UM_USER_NAME", + :um_user_name, # "UM_USER_NAME", :wso2_legacy_password_hash, # "UM_USER_PASSWORD", :wso2_legacy_password_salt, # "UM_SALT_VALUE", :_um_changed_time, # "UM_CHANGED_TIME", diff --git a/app/domain/sac_imports/wso2/person_entry.rb b/app/domain/sac_imports/wso2/person_entry.rb index eb7575cb8..99ecb427f 100644 --- a/app/domain/sac_imports/wso2/person_entry.rb +++ b/app/domain/sac_imports/wso2/person_entry.rb @@ -121,7 +121,7 @@ def assign_new_person_attributes person.birthday = row.birthday person.gender = gender person.language = language - build_phone_number(person, :phone, "Hauptnummer") + build_phone_number(person, :phone, "Haupt-Telefon") build_phone_number(person, :phone_business, "Arbeit") end diff --git a/app/domain/sac_imports/wso2_people_importer.rb b/app/domain/sac_imports/wso2_people_importer.rb index 667fdd68a..6ccd87e9d 100644 --- a/app/domain/sac_imports/wso2_people_importer.rb +++ b/app/domain/sac_imports/wso2_people_importer.rb @@ -19,11 +19,19 @@ class Wso2PeopleImporter :errors ] + UM_USER_NAME_LOG_HEADERS = [ + :hitobito_id, + :um_user_name, + :email + ] + def initialize(output: $stdout) PaperTrail.enabled = false # disable versioning for imports @output = output @source_file = CsvSource.new(:WSO21) @csv_report = CsvReport.new(:"wso21-1_people", REPORT_HEADERS, output:) + @um_user_name_log = CsvReport.new(:"wso21-1_um_user_name_log", + UM_USER_NAME_LOG_HEADERS, output:) @existing_emails = load_existing_emails basic_login_group # warm up to ensure group is present before forking threads abo_group # warm up to ensure group is present before forking threads @@ -71,6 +79,11 @@ def process_row(row) # @output.print(entry.valid? ? " ✅\n" : " ❌ #{entry.error_messages}\n") if entry.valid? entry.import! + @um_user_name_log.add_row( + hitobito_id: entry.person.id, + um_user_name: row.um_user_name, + email: row.email + ) if entry.warning @csv_report.add_row({ navision_id: row.navision_id, diff --git a/spec/domain/sac_imports/wso2/person_entry_spec.rb b/spec/domain/sac_imports/wso2/person_entry_spec.rb index 18856a4a2..7200f2939 100644 --- a/spec/domain/sac_imports/wso2/person_entry_spec.rb +++ b/spec/domain/sac_imports/wso2/person_entry_spec.rb @@ -287,7 +287,7 @@ row[:phone] = "invalid" expect(entry.person.phone_numbers.map(&:number)).to eq [row[:phone_business]] expect(entry.person.notes.map(&:text)).to eq [ - "Importiert mit ungültiger Telefonnummer Hauptnummer: 'invalid'" + "Importiert mit ungültiger Telefonnummer Haupt-Telefon: 'invalid'" ] end end