You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Normalise country/ni and country/northern_ireland before the economy cache lookup #4037
A UK request for Northern Ireland can arrive as country/ni (the UK metadata name, which the app sends) or as country/northern_ireland (the name in policyengine.py's UK region registry). The API maps the name only when it builds the simulation API payload, in EconomyService._setup_region (policyengine_api/services/economy_service.py, via UK_REGION_REGISTRY_CODES in constants.py). _with_normalized_region normalises US regions only, so the economy cache key is built from the region as requested.
As a result, the same Northern Ireland run (national or breakdown=local_areas) gets two cache entries and can be computed twice, once for each name. This came up in the review of #4024 (point 2).
Impact
Small today: the app always sends country/ni. It matters for any client that uses the registry name, and it doubles the cost of a Northern Ireland run when both names are used.
Proposed fix
Normalise UK regions before the cache lookup, in the same place as the US normalisation: map country/northern_ireland to one canonical name (or map both to the registry name), so both names share one cache entry. Keep saved records and existing URLs working. Add a test that both names resolve to the same cache key.
Activity