fix(typo): use english for normalized addresses component
This commit is contained in:
parent
8266f7ff6c
commit
366c02dbb7
6 changed files with 35 additions and 13 deletions
|
@ -140,7 +140,7 @@ class APIGeoService
|
||||||
postal_code = address[:code_postal]
|
postal_code = address[:code_postal]
|
||||||
city_name_fallback = address[:commune]
|
city_name_fallback = address[:commune]
|
||||||
city_code = address[:code_insee]
|
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 }
|
commune = communes_by_postal_code(postal_code).find { _1[:code] == city_code }
|
||||||
if commune.present?
|
if commune.present?
|
||||||
[commune[:departement_code], commune[:region_code]]
|
[commune[:departement_code], commune[:region_code]]
|
||||||
|
@ -149,15 +149,18 @@ class APIGeoService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
department_name = departement_name(department_code)
|
||||||
{
|
{
|
||||||
street_number: address[:numero_voie],
|
street_number: address[:numero_voie],
|
||||||
street_name: address[:libelle_voie],
|
street_name: address[:libelle_voie],
|
||||||
street_address: address[:libelle_voie].present? ? [address[:numero_voie], address[:type_voie], address[:libelle_voie]].compact.join(' ') : nil,
|
street_address: address[:libelle_voie].present? ? [address[:numero_voie], address[:type_voie], address[:libelle_voie]].compact.join(' ') : nil,
|
||||||
postal_code: postal_code.presence || '',
|
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 || '',
|
city_code: city_code.presence || '',
|
||||||
departement_code:,
|
departement_code: department_code,
|
||||||
departement_name: departement_name(departement_code),
|
department_code:,
|
||||||
|
departement_name: department_name,
|
||||||
|
department_name:,
|
||||||
region_code:,
|
region_code:,
|
||||||
region_name: region_name(region_code)
|
region_name: region_name(region_code)
|
||||||
}
|
}
|
||||||
|
@ -167,7 +170,7 @@ class APIGeoService
|
||||||
postal_code = address[:postalCode]
|
postal_code = address[:postalCode]
|
||||||
city_name_fallback = address[:cityName]
|
city_name_fallback = address[:cityName]
|
||||||
city_code = address[:cityCode]
|
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 }
|
commune = communes_by_postal_code(postal_code).find { _1[:code] == city_code }
|
||||||
if commune.present?
|
if commune.present?
|
||||||
[commune[:departement_code], commune[:region_code]]
|
[commune[:departement_code], commune[:region_code]]
|
||||||
|
@ -175,16 +178,19 @@ class APIGeoService
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
department_name = departement_name(department_code)
|
||||||
|
|
||||||
{
|
{
|
||||||
street_number: address[:streetNumber],
|
street_number: address[:streetNumber],
|
||||||
street_name: address[:streetName],
|
street_name: address[:streetName],
|
||||||
street_address: address[:streetAddress],
|
street_address: address[:streetAddress],
|
||||||
postal_code: postal_code.presence || '',
|
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 || '',
|
city_code: city_code.presence || '',
|
||||||
departement_code:,
|
departement_code: department_code,
|
||||||
departement_name: departement_name(departement_code),
|
department_code:,
|
||||||
|
departement_name: department_name,
|
||||||
|
department_name:,
|
||||||
region_code:,
|
region_code:,
|
||||||
region_name: region_name(region_code)
|
region_name: region_name(region_code)
|
||||||
}
|
}
|
||||||
|
@ -194,7 +200,7 @@ class APIGeoService
|
||||||
postal_code = etablissement.code_postal
|
postal_code = etablissement.code_postal
|
||||||
city_name_fallback = etablissement.localite.presence || ''
|
city_name_fallback = etablissement.localite.presence || ''
|
||||||
city_code = etablissement.code_insee_localite
|
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 }
|
commune = communes_by_postal_code(postal_code).find { _1[:code] == city_code }
|
||||||
if commune.present?
|
if commune.present?
|
||||||
[commune[:departement_code], commune[:region_code]]
|
[commune[:departement_code], commune[:region_code]]
|
||||||
|
@ -203,15 +209,19 @@ class APIGeoService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
department_name = departement_name(department_code)
|
||||||
|
|
||||||
{
|
{
|
||||||
street_number: etablissement.numero_voie,
|
street_number: etablissement.numero_voie,
|
||||||
street_name: etablissement.nom_voie,
|
street_name: etablissement.nom_voie,
|
||||||
street_address: etablissement.nom_voie.present? ? [etablissement.numero_voie, etablissement.type_voie, etablissement.nom_voie].compact.join(' ') : nil,
|
street_address: etablissement.nom_voie.present? ? [etablissement.numero_voie, etablissement.type_voie, etablissement.nom_voie].compact.join(' ') : nil,
|
||||||
postal_code: postal_code.presence || '',
|
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 || '',
|
city_code: city_code.presence || '',
|
||||||
departement_code:,
|
departement_code: department_code,
|
||||||
departement_name: departement_name(departement_code),
|
department_code:,
|
||||||
|
departement_name: department_name,
|
||||||
|
department_name:,
|
||||||
region_code:,
|
region_code:,
|
||||||
region_name: region_name(region_code)
|
region_name: region_name(region_code)
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,9 @@ describe Champs::RNAController, type: :controller do
|
||||||
"city_code" => "75108",
|
"city_code" => "75108",
|
||||||
"city_name" => "Paris",
|
"city_name" => "Paris",
|
||||||
"departement_code" => nil, # might seem broken lookup, but no, it's anonymized
|
"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,
|
"departement_name" => nil,
|
||||||
|
"department_name" => nil,
|
||||||
"postal_code" => "75009",
|
"postal_code" => "75009",
|
||||||
"region_code" => nil,
|
"region_code" => nil,
|
||||||
"region_name" => nil,
|
"region_name" => nil,
|
||||||
|
|
|
@ -109,7 +109,9 @@ describe Champs::RNFChamp, type: :model do
|
||||||
:city_name => "Paris 15e Arrondissement",
|
:city_name => "Paris 15e Arrondissement",
|
||||||
:city_code => "75115",
|
:city_code => "75115",
|
||||||
:departement_code => "75",
|
:departement_code => "75",
|
||||||
|
:department_code => "75",
|
||||||
:departement_name => "Paris",
|
:departement_name => "Paris",
|
||||||
|
:department_name => "Paris",
|
||||||
:region_code => "11",
|
:region_code => "11",
|
||||||
:region_name => "Île-de-France"
|
:region_name => "Île-de-France"
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,9 @@ module Maintenance
|
||||||
"city_name" => "Paris",
|
"city_name" => "Paris",
|
||||||
"city_code" => "75108",
|
"city_code" => "75108",
|
||||||
"departement_code" => nil,
|
"departement_code" => nil,
|
||||||
|
"department_code" => nil,
|
||||||
"departement_name" => nil,
|
"departement_name" => nil,
|
||||||
|
"department_name" => nil,
|
||||||
"region_code" => nil,
|
"region_code" => nil,
|
||||||
"region_name" => nil
|
"region_name" => nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -62,7 +62,9 @@ module Maintenance
|
||||||
"city_name" => "Paris 15e Arrondissement",
|
"city_name" => "Paris 15e Arrondissement",
|
||||||
"city_code" => "75115",
|
"city_code" => "75115",
|
||||||
"departement_code" => "75",
|
"departement_code" => "75",
|
||||||
|
"department_code" => "75",
|
||||||
"departement_name" => "Paris",
|
"departement_name" => "Paris",
|
||||||
|
"department_name" => "Paris",
|
||||||
"region_code" => "11",
|
"region_code" => "11",
|
||||||
"region_name" => "Île-de-France"
|
"region_name" => "Île-de-France"
|
||||||
})
|
})
|
||||||
|
@ -86,7 +88,9 @@ module Maintenance
|
||||||
"city_name" => "Paris 15e Arrondissement",
|
"city_name" => "Paris 15e Arrondissement",
|
||||||
"city_code" => "75115",
|
"city_code" => "75115",
|
||||||
"departement_code" => "75",
|
"departement_code" => "75",
|
||||||
|
"department_code" => "75",
|
||||||
"departement_name" => "Paris",
|
"departement_name" => "Paris",
|
||||||
|
"department_name" => "Paris",
|
||||||
"region_code" => "11",
|
"region_code" => "11",
|
||||||
"region_name" => "Île-de-France"
|
"region_name" => "Île-de-France"
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,7 +23,9 @@ module Maintenance
|
||||||
"street_number" => "6",
|
"street_number" => "6",
|
||||||
"street_address" => "6 RUE RAOUL NORDLING",
|
"street_address" => "6 RUE RAOUL NORDLING",
|
||||||
"departement_code" => "92",
|
"departement_code" => "92",
|
||||||
"departement_name" => "Hauts-de-Seine"
|
"department_code" => "92",
|
||||||
|
"departement_name" => "Hauts-de-Seine",
|
||||||
|
"department_name" => "Hauts-de-Seine"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue