-
-
Notifications
You must be signed in to change notification settings - Fork 314
Add ability to filter aggregate data #122
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
Conversation
|
I really like the way this was solved, nicely done. This should probably be documented in the README.md under the /latest endpoint :). |
|
Also, not a 100% sure if /latest should be responsible for the aggregation. Maybe it should instead be moved to /locations, and be put under “aggregated” or “latest” top-level? What do you think?? |
|
How is about testcases? |
|
@gribok that - i do not know XD |
|
Not sure about testcases. I'm not really sure what you mean by aggregated or latest top-level, would you mind explaining in more detail? (Sorry if these are really basic things I should know as a developer, I'm quite new to all this) |
|
Like this: /v2/locations?country_code=USreturns {
"latest": {
"confirmed": 100000,
"deaths": 4000,
"recovered": 70000
},
"locations": [
]
}"latest" being the sum of "latest" from all the locations returned (aggregated). Not sure whether we should call it latest or aggregated though. All you do is basically move your code from And it's okay aha @SeanCena |
… filter locations by attributes other than just country_code
|
Very nicely done! Could you perhaps rename it to "latest" instead? I think overall it would make more sense given that's what it's called inside the locations, then I'll go ahead and merge. |
|
Thanks, I moved the latest() code to locations(). For now, I put the aggregate data under "aggregate". Also, one of the side effects is that you can now pass any attribute (not just country_code) as an argument to /locations, which I just realized includes the double-underscore attributes of the timelinedlocations class. Might be a security issue, idk? Other than that, everything seems to work fine. In response to your new comment, yes, I will rename it to latest. |
Also prevented user from filtering by double-underscore functions
|
Thanks a lot! Looks good. Merging. |
|
@all-contributors please add @SeanCena for code, documentation, and tests. |
|
I've put up a pull request to add @SeanCena! 🎉 |
A very very minimal edit, but it would allow users to get aggregate data by country_code, province, etc. by adding a filter as a GET parameter.
GET /api/v2/latest?country_code=USwould solve #108 , for instance.