-
Notifications
You must be signed in to change notification settings - Fork 30
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
Your Stats makes an expensive GET request on every classification #6588
Comments
Complaints about a slow endpoint with examples should go to the eras repo: https://github.com/zooniverse/eras. The frontend does what it can to ensure accurate stats displayed to all users. We would welcome a PR on FEM regarding the SWR + mutate strategy to improve the YourProjectStats component. |
If you'd like me to work on this, I'd be happy to do that, but you'll need to get in touch with us and ask Oxford for some of my time. |
The bug here isn't in ERAS (although a faster API would obviously be better.) The frontend is making repeated HTTP requests for data that it already has. That's going to cause performance problems, particularly when the number of incoming classifications is high. |
I did take a quick look at the code. This line, which runs after every classification, fetches the user stats from eras.zooniverse.org when the Line 64 in 51f064e
|
The problem is, that code is fetching counts that are already displayed in the Your Stats box. |
Package
Describe the bug
Every time I press Done now, the Your Stats component makes a request to ERAS that takes ~2s. It's fetching yearly stats for my account, all the way back to 2009, after every new classification.
https://eras.zooniverse.org/classifications/users/149/?end_date=2024-12-19&period=year&start_date=2009-03-25&project_id=8149
You can see the request in the browser network panel. I've highlighted it in Firefox here, where the browser has flagged it as a slow-running request.
To Reproduce
Submit a classification on any project and watch the network requests made by the browser.
Expected behavior
Responses to expensive requests should probably be cached in the browser, or in the React app, and reused eg. the number of classifications I made since 2009 isn't going to change, so doesn't need to be fetched after every classification. You could cache the all-time count when the page first loads, or on visibility change, then simply increment in the browser when the Done button is pressed.
Additional context
@mutabilitie
says the stats counts are laggy in this Talk thread. That might be related to the API being slow, or a slow API endpoint being requested too frequently.What are optimistic updates? explains how to improve responsiveness by showing updates immediately.
useOptimistic
in React 19.The text was updated successfully, but these errors were encountered: