Closed TeachMeTW closed 1 month ago
This PR would need a squash due to my extensive commits
@JGreenlee @TeachMeTW I looked at this a while ago and came up with a plan (or two) but didn't have time to implement. The key here is to really dig into the user model and understand that the user stats consists of two separate parts:
Reading the first is super fast, because it is a single small table Reading the second is very slow because we have to essentially query for the entire trip table
We should fix this by:
Ah I think it was Patch
that I originally found for lazily updating data
https://plotly.com/blog/partial-properties/
@shankari I made progress in regards to the lazy loading, the only thing I'd need to figure out is how to stop it from refreshing the ui. I tried to use Patch() but seems to not work fully as intended yet; I'll keep at it.
See below:
https://github.com/user-attachments/assets/f904005c-8f83-4cbf-81a1-cd48d59b21e5
@shankari Progress, discussed with @JGreenlee to help resolve some of the issues I was facing; now loads without reloading the entire thing.
https://github.com/user-attachments/assets/bd12efa9-4dde-442f-b248-ef8a04ad4816
Squash merging this as well, make sure to pull the changes before starting on the next PR, @TeachMeTW
Description
This pull request introduces several performance improvements to the data page:
Changes Made
1. Timer Integration
Added timing to measure the execution time of the
add_user_stats
function and other functions.2. Lazy Loading Implementation
Replaced sequential user processing with batch processing; batches can be set in add_user_stats in db_utils for default value changes or in render_content in data.py
Each batch of 10 takes about ~7 seconds of processing.