Merge pull request #11164 from colinux/faster-api

Tech: API Geo: cache communes by code postal pour ne pas désérialiser en permanence les communes
This commit is contained in:
Colin Darie 2024-12-20 09:06:37 +00:00 committed by GitHub
commit 950e3ba859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,9 +81,11 @@ class APIGeoService
end
def communes_by_postal_code(postal_code)
communes_by_postal_code_map.fetch(postal_code, [])
.filter { !_1[:code].in?(['75056', '13055', '69123']) }
.sort_by { I18n.transliterate([_1[:name], _1[:postal_code]].join(' ')) }
Rails.cache.fetch("api_geo_communes_by_pc_#{postal_code}", expires_in: 1.week, version: 3) do
communes_by_postal_code_map.fetch(postal_code, [])
.filter { !_1[:code].in?(['75056', '13055', '69123']) }
.sort_by { I18n.transliterate([_1[:name], _1[:postal_code]].join(' ')) }
end
end
def commune_name(departement_code, code)