Enable multiple filters to be supplied by using get_resource_sql
#54
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.
I was working with @peterl04. He was using https://www.opendata.nhs.scot/dataset/prescriptions-in-the-community but needed data on specific drugs from a number of practices for ~2 years (24 resources). Each resource takes 30+ seconds to fully download, so filtering is super useful. However, only being able to filter by one drug and practice at a time is quite limiting and makes the code more complicated.
This change worked for me. It just uses
get_resource_sql
when multiple filters are supplied and generates some appropriate SQL.I think it could probably do with more tests, especially for incorrect or weird/edge cases. I tried to do it using existing functions as much as possible.
One thing to note is that
get_resource_sql
is slower thanget_resource
so there could be a better way of doing this...