-
Notifications
You must be signed in to change notification settings - Fork 88
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 support for a 'country' filter in query parameters #302
Conversation
28682e2
to
8150dd8
Compare
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
mapit/views/areas.py
Outdated
args['polygons__in'] = geoms | ||
areas = Area.objects.filter(**args) | ||
geoms = list(Geometry.objects.filter(polygon__contains=location).defer('polygon')) | ||
args['polygons__in'] = geoms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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