Skip to content

Conversation

@anth-volk
Copy link
Collaborator

@anth-volk anth-volk commented Dec 15, 2025

Fixes #2989

Should be merged alongside a corresponding front-end PR in app v2 (not yet created)

@PolicyEngine write up a description of this PR

Copy link

@policyengine policyengine bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR successfully adds UK local authority breakdown support to the API, mirroring the existing constituency breakdown feature. The implementation is solid and well-tested.

What this adds:

  • New local_authority region type in constants
  • 360 local authorities across England, Scotland, Wales, and Northern Ireland
  • uk_local_authority_breakdown() function that calculates income impacts by local authority
  • Filtering support for specific local authorities and countries
  • Comprehensive unit tests with good coverage

Code Quality:

  • Follows existing patterns from constituency breakdown
  • Proper separation of concerns with Pydantic models
  • Good test coverage including edge cases
  • No syntax errors

Minor observations (non-blocking):

  • The local authority filtering uses code.startswith() (compare.py:737-746) which is more accurate than the constituency code's "E" in code pattern (compare.py:626, 652), but both approaches work correctly for the actual UK region codes
  • Consistent pattern of mutual exclusion: constituency regions skip LA breakdown, LA regions skip constituency breakdown

The implementation correctly handles all the required functionality and integrates cleanly with the existing codebase.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 76.47059% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.25%. Comparing base (1c10af2) to head (76ec682).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
policyengine_api/endpoints/economy/compare.py 75.00% 15 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2992      +/-   ##
==========================================
- Coverage   74.87%   70.25%   -4.63%     
==========================================
  Files          54       55       +1     
  Lines        2026     2353     +327     
  Branches      268      333      +65     
==========================================
+ Hits         1517     1653     +136     
- Misses        459      639     +180     
- Partials       50       61      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anth-volk anth-volk merged commit c564e3b into master Dec 16, 2025
6 of 7 checks passed
@anth-volk anth-volk deleted the feat/add-uk-local-authorities branch December 16, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable calculation of UK local authority-level results and add UK local authority metadata

2 participants