Skip to content
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

Merged
merged 20 commits into from
Feb 5, 2025

Conversation

gmechali
Copy link
Contributor

@gmechali gmechali commented Feb 3, 2025

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.

…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.
@gmechali gmechali marked this pull request as ready for review February 5, 2025 00:19
@gmechali gmechali requested a review from dwnoble February 5, 2025 00:19
@gmechali gmechali changed the title [Place Page Revamp] Fix one chart + add api tests - wip [Place Page Revamp] Fix one chart and add API Tests Feb 5, 2025
@@ -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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere?

Copy link
Contributor Author

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.

@gmechali gmechali merged commit 7ed7b19 into datacommonsorg:master Feb 5, 2025
8 checks passed
@gmechali gmechali deleted the charts branch February 5, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants