-
Notifications
You must be signed in to change notification settings - Fork 21
Add JSON Endpoints for /find-local-council for App to query #4710
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- although it might normally be a factory or service item, this class is relatively simple so we also add a method to build from a local custodian code. - Local links manager always returns 2-tier councils with the district first, then county, so it's safe to rely on that order. It only ever returns 1 or 2, not found will throw a GdsApi error which a controller can handle reasonably.
- this promotes it into being able to be raised/caught, which the name implies it should be.
- for initial refactoring, it makes sense to encapsulate this. It's not quite a Location model yet, but we can improve on it later.
- Here although we're making the action a bit bigger, we're removing a lot of private code and turning the inverted code (where we try to get the error and work with the side-effects of that) into more straightforward, readable code with exception paths.
- These actually change _very_ infrequently, but 5 minutes is a common caching time for gov.uk, so we shouldn't introduce a surprise longer cache without very good reason.
- Since we do a bunch of checking in the initializer, and we can't call addresses without an object, it's safe to skip a bunch of error checking here (we know we're going to get _something_). - We don't strictly need to make the postcode attribute readable outside the model, but it seems a reasonable thing to do.
- AddressListPresenter takes a list of addresses (from a PostcodeLookup) and reformats them to the format wanted by the component, also doing a lookup to find the slug from the lcc. - Get rid of @addresses which was only used for the count > 6 check (we can just use the output from the presenter, which is more appropriate anyway) - we don't need the SplitPostcodeSupport concern at this point.
- Refactor the making into a private class method so it can be used for response from other methods. - Handle two-tier correctly - we can't always assume they'll come back in order, and we can't always assume the top-tier will be a county (it might occasionally be a unitary if we're in the middle of local-authority merges). So if there are two results, the parent will be whatever is not a district (usually county, sometimes unitary), and the child/singleton will be whatever is not a county (either a district in a two-tier, or a unitary in a one-tier).
- We will also want to load the model from a slug, so add a method to do that.
- Now we can get a proper LocalAuthority model by slug, we can simplify this method, and make the templates a little nicer.
57cd120
to
4c1ffff
Compare
Closing in favour of this: #4720 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Why
https://trello.com/c/YX1VcZj0/335-create-json-endpoint-version-of-find-local-council-for-app
How
Screenshots?