From 9f9370d8550073101801d8dad0dbfb9370281153 Mon Sep 17 00:00:00 2001 From: Diego Steiner Date: Fri, 20 Oct 2023 11:51:23 +0200 Subject: [PATCH 1/3] add language mapping for nds export --- app/domain/export/tabular/people/participation_nds_row.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/domain/export/tabular/people/participation_nds_row.rb b/app/domain/export/tabular/people/participation_nds_row.rb index 2263b010..4beed4fa 100644 --- a/app/domain/export/tabular/people/participation_nds_row.rb +++ b/app/domain/export/tabular/people/participation_nds_row.rb @@ -7,6 +7,7 @@ module Export::Tabular::People class ParticipationNdsRow < Export::Tabular::People::PersonRow + NDS_LANGUAGE_MAPPING = %w[DE FR IT].to_h { [_1, _1] }.freeze attr_reader :participation @@ -68,7 +69,7 @@ def email_work end def first_language - 'DE' + NDS_LANGUAGE_MAPPING.fetch(entry.language.presence&.to_s&.upcase, 'Andere') end def second_language From 8b1000eff7f88ce645d29b1f5ca02b2be5633925 Mon Sep 17 00:00:00 2001 From: Diego Steiner Date: Fri, 20 Oct 2023 14:20:32 +0200 Subject: [PATCH 2/3] add language mapping for nds export --- .../tabular/people/participation_nds_row.rb | 5 +++-- .../people/participation_nds_row_spec.rb | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/domain/export/tabular/people/participation_nds_row.rb b/app/domain/export/tabular/people/participation_nds_row.rb index 4beed4fa..e0522584 100644 --- a/app/domain/export/tabular/people/participation_nds_row.rb +++ b/app/domain/export/tabular/people/participation_nds_row.rb @@ -7,7 +7,7 @@ module Export::Tabular::People class ParticipationNdsRow < Export::Tabular::People::PersonRow - NDS_LANGUAGE_MAPPING = %w[DE FR IT].to_h { [_1, _1] }.freeze + NDS_LANGUAGES = %w[DE FR IT].freeze attr_reader :participation @@ -69,7 +69,8 @@ def email_work end def first_language - NDS_LANGUAGE_MAPPING.fetch(entry.language.presence&.to_s&.upcase, 'Andere') + language = entry.language.presence&.to_s&.upcase + NDS_LANGUAGES.include?(language) ? language : 'Andere' end def second_language diff --git a/spec/domain/export/tabular/people/participation_nds_row_spec.rb b/spec/domain/export/tabular/people/participation_nds_row_spec.rb index f6663b44..d1c3f137 100644 --- a/spec/domain/export/tabular/people/participation_nds_row_spec.rb +++ b/spec/domain/export/tabular/people/participation_nds_row_spec.rb @@ -43,6 +43,24 @@ it { expect(row.fetch(:nationality_j_s)).to eq 'ANDERE' } end + describe 'first_language' do + context 'with supported language' do + before do + person.language = :fr + end + + it { expect(row.fetch(:first_language)).to eq 'FR' } + end + + context 'with unsupported language' do + before do + person.language = :en + end + + it { expect(row.fetch(:first_language)).to eq 'Andere' } + end + end + describe 'j_s_number format' do before do person.j_s_number = '169-55-79' From b237d3dc2c80071dfa0678a321e7f9458690b5fa Mon Sep 17 00:00:00 2001 From: Diego Steiner <939106+diegosteiner@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:07:18 +0200 Subject: [PATCH 3/3] Update participation_nds_row.rb --- app/domain/export/tabular/people/participation_nds_row.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/domain/export/tabular/people/participation_nds_row.rb b/app/domain/export/tabular/people/participation_nds_row.rb index a1ecc2ae..c0fd399c 100644 --- a/app/domain/export/tabular/people/participation_nds_row.rb +++ b/app/domain/export/tabular/people/participation_nds_row.rb @@ -72,7 +72,7 @@ def email_work def first_language language = entry.language.presence&.to_s&.upcase - NDS_LANGUAGES.include?(language) ? language : 'Andere' + NDS_LANGUAGES.include?(language) ? language : "Andere" end def second_language