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

Hit static landing page data #768

Merged
merged 2 commits into from
Jul 15, 2023
Merged

Conversation

PatrickCleary
Copy link
Member

Motivation

The landing page data was slow to load on the first query.

Changes

Fetch landing page data from /static folder. Uploaded by a lambda in this pr: transitmatters/data-ingestion#33

Add a "primer query" to landing page to get the lambdas warm for when the user goes to next page.

Testing Instructions

Check landing page -> make sure data is all there.

@PatrickCleary PatrickCleary added v4 backend Change to backend code labels Jul 14, 2023
@PatrickCleary PatrickCleary self-assigned this Jul 14, 2023
@github-actions github-actions bot added dependencies Changes to dependencies frontend Change to frontend code and removed backend Change to backend code labels Jul 14, 2023
@PatrickCleary PatrickCleary marked this pull request as ready for review July 14, 2023 22:45
useQuery(
['primer'],
() =>
fetchActualTripsByLine({
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts about making this a query that might actually get called later so we can also benefit from the local cache? Right now this is under the key primer and therefore this cached call will never be used. Either remove the ONE_HOUR local cache or hit an endpoint with params/keys that might be called on a subsequent page

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's an interesting point, and I was thinking about it for a bit. I think if we try to use a useful value, we're more likely to create more wasteful operations. We have no idea what the user is gonna do next, so the query is likely to end up not being used anyway.

I also think this solution is a bit hacky and I hope to have a better fix in the future, so I think keeping it clearly a "useless" function with the name primer reduces the odds that it causes confusion down the line. Whereas the performance benefits seem very minor at best.

Copy link
Member

Choose a reason for hiding this comment

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

At least use useDeliveredTripMetrics with the set of params you used here, so the cache could be used

Copy link
Member

@devinmatte devinmatte left a comment

Choose a reason for hiding this comment

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

Looks good, just one thought about trying to be practical with cache

useQuery(
['primer'],
() =>
fetchActualTripsByLine({
Copy link
Member

Choose a reason for hiding this comment

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

At least use useDeliveredTripMetrics with the set of params you used here, so the cache could be used

@PatrickCleary PatrickCleary merged commit f59acc3 into dashboard-v4 Jul 15, 2023
5 checks passed
@PatrickCleary PatrickCleary deleted the v4/landing-page-data branch July 15, 2023 21:18
@devinmatte devinmatte added this to the Dashboard V4 milestone Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Changes to dependencies frontend Change to frontend code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants