Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UK Parliamentary constituencies #2370

Merged
merged 17 commits into from
Feb 27, 2025
Merged

Conversation

nikhilwoodruff
Copy link
Contributor

@nikhilwoodruff nikhilwoodruff commented Feb 20, 2025

Fixes #2369

Requires PolicyEngine/policyengine-api#2195 to be merged first.

Description

Added UK constituency regions, plus three charts.

Changes

Please describe the changes in detail.

Screenshots

Screen.Recording.2025-02-20.at.17.05.24.mov

Tests

None.

@nikhilwoodruff nikhilwoodruff added the enhancement New feature or request label Feb 20, 2025
@nikhilwoodruff nikhilwoodruff self-assigned this Feb 20, 2025
Copy link

vercel bot commented Feb 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
policyengine-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2025 10:46am

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

Thanks for this @nikhilwoodruff. I attempted to run this locally, but using the deployed API (which now contains the API changes necessary to enable this feature), but after trying to run a standard reform (http://localhost:3000/uk/policy?focus=policyOutput.policyBreakdown&reform=76682&region=uk&timePeriod=2025&baseline=1), I get a "Sorry, something went wrong", and the network tab shows that there is a calculation error somewhere on the back end.

@nikhilwoodruff
Copy link
Contributor Author

Thanks @anth-volk - I think it might be fixed by this PR.

@nikhilwoodruff
Copy link
Contributor Author

Also adding to this the feedback from @MaxGhenis that we should split out the winner/loser chart by UK country.

@nikhilwoodruff
Copy link
Contributor Author

nikhilwoodruff commented Feb 24, 2025

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

  1. Running this code against the prod API with a reform over a country (e.g., http://localhost:3000/uk/policy?focus=policyOutput.povertyImpact.regular.byAge&reform=76756&region=country%2Fengland&timePeriod=2025&baseline=1) crashes for me.
  2. All constituencies are available in the region selection pane, so if I select one without the beta URL parameter, I'm not sure how this behavior is handled, because...
  3. Even with the beta URL parameter, the site crashes for me. I believe this may be due to PoliciesModelledPopup, which you may not be seeing locally due to having cookies enabled, but I believe I'm testing with them disabled.
  4. Looks like tests don't currently run because of a lint failure.

@nikhilwoodruff
Copy link
Contributor Author

Can you provide a preview link that crashes? I can't reproduce so far.

@nikhilwoodruff
Copy link
Contributor Author

On 3., good point. I'll hide them without the query parameter.

@anth-volk
Copy link
Collaborator

The below link breaks for me: https://policyengine-app-git-nikhilwoodruff-issue2369-policy-engine.vercel.app/uk/policy?focus=policyOutput.policyBreakdown&reform=76756&region=country%2Fengland&timePeriod=2025&baseline=1

I'm guessing this is at least partly because I clicked to deny cookies when the pop-up came up. In order to reproduce, you might have to empty your own.

@nikhilwoodruff
Copy link
Contributor Author

Can you try again now, with the API update?

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

Thanks for the back-end changes @nikhilwoodruff, I now was able to get this running. I have a few questions & suggestions and one or two places where I think changes to implementation might be warranted. Looking forward to your thoughts! This is a very cool feature, glad to see this in action.

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

Very cool feature @nikhilwoodruff. Per our discussion, I've flagged one issue that's still occurring, but will open as a separate issue.

return !!searchParams[param];
};
const uk_local_areas_beta = hasParam("uk_local_areas_beta")
? searchParams.get("uk_local_areas_beta")
Copy link
Collaborator

Choose a reason for hiding this comment

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

issue, non-blocking: I believe this will show unintended outputs when the URL param uk_local_areas_beta is given any value

I'm not 100% positive on the causality, partly because getPolicyOutputTree is a quite limiting function that I'd opt to deprecate in front end v2, but here's what happens:

  1. I, as a user inputting a policy, toggle "Enable UK local areas" to "on", adding "uk_local_areas_beta=true" to the URL
  2. I then toggle it to "off", updating the URL param to "uk_local...=false"
  3. If I visit this URL, which contains that param, I can still see the beta output items

I'm going to merge this code, but open this as a separate issue. Flagging here for down the road.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Created as #2381

@anth-volk anth-volk merged commit 48e715d into master Feb 27, 2025
4 checks passed
@anth-volk anth-volk deleted the nikhilwoodruff/issue2369 branch February 27, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add UK Parliamentary constituencies
2 participants