Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Normalise country/ni and country/northern_ireland before the economy cache lookup

未关闭 适合新手
#4,037 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
api, backend, databases

调研方向

从 policyengine_api/services/economy_service.py 开始,阅读 _with_normalized_region,并结合 constants.py 中的 _setup_region 和 UK_REGION_REGISTRY_CODES,了解缓存键和模拟负载如何使用地区名称。添加所要求的测试,证明北爱尔兰的两种名称会解析到同一个缓存键,同时确保已保存的记录和现有 URL 继续正常工作;测试通过且两个请求共享同一个缓存条目即为完成。

由索引模型根据 Issue 内容生成。

描述

Problem

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.

🤖 Generated with Claude Code

主要语言
Python
星标
18
派生
33
平均合并
2 天 16 小时
30 天内合并 PR
53

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PolicyEngine/policyengine-api 的其他 Issue

查看 PolicyEngine/policyengine-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。