-
Notifications
You must be signed in to change notification settings - Fork 91
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
[Place Page Revamp] Fix one chart and add API Tests #4922
Conversation
…arallelize expensive operations (datacommonsorg#4912) With some of the recent place page work, the latency on the api calls has reached levels above what we should. This PR adds parallelization to our expensive operations with the related_places, and chats endpoints for the revamped place page. This also refactors the code significantly to reuse code across different parts of the functions, and create more granular helper functions. In a follow up PR I will add thorough testing on all these helpers and the main api endpoints. See Latency with this PR applied: https://paste.googleplex.com/4715161129320448 See latency without this PR: https://paste.googleplex.com/5451439923789824 Essentially, this leads to an approximately 40-50% speed up in the charts endpoint, and 30-40% for the related places endpoint.
@@ -442,6 +443,17 @@ async def fetch_and_process_stats(): | |||
return valid_chart_configs | |||
|
|||
|
|||
@cache.memoize(timeout=TIMEOUT) | |||
async def memoized_filter_chart_config_for_data_existence( |
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.
Is this used anywhere?
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.
ah that was my bad. this is supposed to be called from the API since we still want the memoization to happen. I moved this into a separate method because the cache.memoize annotation was causing some issues with the tests starting up since we don't have the cache initialization in this. I tried messing with it but couldn't figure it out. I can try again, but having the memoized method, and the implemetnation separate worked fine. just a little code duplication.
But the function there is now pretty well tested.
Fixes one chart metadata to remove scaling on units that don't need it.
Adds significant test coverage across our utils for the new place page. Creates helpers for mocking data. More testing to come.