Add support for a 'country' filter in query parameters#302
Merged
Conversation
28682e2 to
8150dd8
Compare
Contributor
Author
|
n.b. The test failures here are due to changes in the Travis build environment - I've made a pull request with fixes for those errors here so once that's merge, this should be rebased over that. |
8150dd8 to
96b83ed
Compare
96b83ed to
293c06f
Compare
dracos
reviewed
Oct 25, 2017
| args['polygons__in'] = geoms | ||
| areas = Area.objects.filter(**args) | ||
| geoms = list(Geometry.objects.filter(polygon__contains=location).defer('polygon')) | ||
| args['polygons__in'] = geoms |
Member
There was a problem hiding this comment.
To continue this, these two lines could now be args['polygons__polygon__contains'] = location I assume?
887491d to
50adce0
Compare
This change means that you can add '?country=E' (say) to queries for multiple areas to restrict the results to those areas that have a Country with code 'E'. This should be particularly helpful for global.mapit.mysociety.org if we set an appropriate Country for each Area, since one is almost always interested in results from a particular country. Fixes #55
Presumably the same fix for odd PostGIS query planning needs to be done for the new 'country' filter as for 'type', since these GET query parameters modify the shape of the query in the same way.
We have migrated MapIt to use Postgres 9.6 and PostGIS 2.3 now; Matthew Somerville investigated whether this sub-optimal query planning still happens with those versions, but it doesn't seem to. The query time is considerably faster as well. So, we believe that this workaround should no longer be necessary, but this commit should revert cleanly if in practice we discover the problem is still present with some other variant of these queries or data.
afc4a02 to
4210423
Compare
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
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.
This change means that you can add
?country=E(say) to queries formultiple areas to restrict the results to those areas that have a
Country with code
E.This should be particularly helpful for global.mapit.mysociety.org
if we set an appropriate Country for each Area, since one is almost
always interested in results from a particular country.
Fixes #55