fix(typo): use english for normalized addresses component

This commit is contained in:
mfo 2024-10-14 09:54:17 +02:00
parent 8266f7ff6c
commit 366c02dbb7
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
6 changed files with 35 additions and 13 deletions

View file

@ -140,7 +140,7 @@ class APIGeoService
postal_code = address[:code_postal]
city_name_fallback = address[:commune]
city_code = address[:code_insee]
departement_code, region_code = if postal_code.present? && city_code.present?
department_code, region_code = if postal_code.present? && city_code.present?
commune = communes_by_postal_code(postal_code).find { _1[:code] == city_code }
if commune.present?
[commune[:departement_code], commune[:region_code]]
@ -149,15 +149,18 @@ class APIGeoService
end
end
department_name = departement_name(department_code)
{
street_number: address[:numero_voie],
street_name: address[:libelle_voie],
street_address: address[:libelle_voie].present? ? [address[:numero_voie], address[:type_voie], address[:libelle_voie]].compact.join(' ') : nil,
postal_code: postal_code.presence || '',
city_name: safely_normalize_city_name(departement_code, city_code, city_name_fallback),
city_name: safely_normalize_city_name(department_code, city_code, city_name_fallback),
city_code: city_code.presence || '',
departement_code:,
departement_name: departement_name(departement_code),
departement_code: department_code,
department_code:,
departement_name: department_name,
department_name:,
region_code:,
region_name: region_name(region_code)
}
@ -167,7 +170,7 @@ class APIGeoService
postal_code = address[:postalCode]
city_name_fallback = address[:cityName]
city_code = address[:cityCode]
departement_code, region_code = if postal_code.present? && city_code.present?
department_code, region_code = if postal_code.present? && city_code.present?
commune = communes_by_postal_code(postal_code).find { _1[:code] == city_code }
if commune.present?
[commune[:departement_code], commune[:region_code]]
@ -175,16 +178,19 @@ class APIGeoService
[]
end
end
department_name = departement_name(department_code)
{
street_number: address[:streetNumber],
street_name: address[:streetName],
street_address: address[:streetAddress],
postal_code: postal_code.presence || '',
city_name: safely_normalize_city_name(departement_code, city_code, city_name_fallback),
city_name: safely_normalize_city_name(department_code, city_code, city_name_fallback),
city_code: city_code.presence || '',
departement_code:,
departement_name: departement_name(departement_code),
departement_code: department_code,
department_code:,
departement_name: department_name,
department_name:,
region_code:,
region_name: region_name(region_code)
}
@ -194,7 +200,7 @@ class APIGeoService
postal_code = etablissement.code_postal
city_name_fallback = etablissement.localite.presence || ''
city_code = etablissement.code_insee_localite
departement_code, region_code = if postal_code.present? && city_code.present?
department_code, region_code = if postal_code.present? && city_code.present?
commune = communes_by_postal_code(postal_code).find { _1[:code] == city_code }
if commune.present?
[commune[:departement_code], commune[:region_code]]
@ -203,15 +209,19 @@ class APIGeoService
end
end
department_name = departement_name(department_code)
{
street_number: etablissement.numero_voie,
street_name: etablissement.nom_voie,
street_address: etablissement.nom_voie.present? ? [etablissement.numero_voie, etablissement.type_voie, etablissement.nom_voie].compact.join(' ') : nil,
postal_code: postal_code.presence || '',
city_name: safely_normalize_city_name(departement_code, city_code, city_name_fallback),
city_name: safely_normalize_city_name(department_code, city_code, city_name_fallback),
city_code: city_code.presence || '',
departement_code:,
departement_name: departement_name(departement_code),
departement_code: department_code,
department_code:,
departement_name: department_name,
department_name:,
region_code:,
region_name: region_name(region_code)
}

View file

@ -126,7 +126,9 @@ describe Champs::RNAController, type: :controller do
"city_code" => "75108",
"city_name" => "Paris",
"departement_code" => nil, # might seem broken lookup, but no, it's anonymized
"department_code" => nil, # might seem broken lookup, but no, it's anonymized
"departement_name" => nil,
"department_name" => nil,
"postal_code" => "75009",
"region_code" => nil,
"region_name" => nil,

View file

@ -109,7 +109,9 @@ describe Champs::RNFChamp, type: :model do
:city_name => "Paris 15e Arrondissement",
:city_code => "75115",
:departement_code => "75",
:department_code => "75",
:departement_name => "Paris",
:department_name => "Paris",
:region_code => "11",
:region_name => "Île-de-France"
}

View file

@ -29,7 +29,9 @@ module Maintenance
"city_name" => "Paris",
"city_code" => "75108",
"departement_code" => nil,
"department_code" => nil,
"departement_name" => nil,
"department_name" => nil,
"region_code" => nil,
"region_name" => nil
})

View file

@ -62,7 +62,9 @@ module Maintenance
"city_name" => "Paris 15e Arrondissement",
"city_code" => "75115",
"departement_code" => "75",
"department_code" => "75",
"departement_name" => "Paris",
"department_name" => "Paris",
"region_code" => "11",
"region_name" => "Île-de-France"
})
@ -86,7 +88,9 @@ module Maintenance
"city_name" => "Paris 15e Arrondissement",
"city_code" => "75115",
"departement_code" => "75",
"department_code" => "75",
"departement_name" => "Paris",
"department_name" => "Paris",
"region_code" => "11",
"region_name" => "Île-de-France"
})

View file

@ -23,7 +23,9 @@ module Maintenance
"street_number" => "6",
"street_address" => "6 RUE RAOUL NORDLING",
"departement_code" => "92",
"departement_name" => "Hauts-de-Seine"
"department_code" => "92",
"departement_name" => "Hauts-de-Seine",
"department_name" => "Hauts-de-Seine"
})
end
end