monkeytype icon indicating copy to clipboard operation
monkeytype copied to clipboard

Save speed stats in leaderboard update

Open mrbrianevans opened this issue 3 years ago • 5 comments

Saves a histogram data structure of speeds for buckets rounded to the nearest 10.

Signed-off-by: Brian Evans [email protected]

Description

I have added to the leaderboard update function to save some global stats for all users. It saves in public collection with type speedStats. The data structure saved is:

{
"type":"speedStats",
"english_time_15":{"110":1},
"english_time_60":{"90":1}
}

Closes #3650

mrbrianevans avatar Oct 14 '22 17:10 mrbrianevans

Status update

Finished:

  • save public stats when leaderboard is calculated
  • serve public stats on endpoint
  • get data on frontend with Ape client

Still todo:

  • implement histogram display logic (following https://github.com/monkeytypegame/monkeytype/commit/7dff50dc3032cd0c7a897da70825892745878a5b) Should look something like this (but with users on the y axis): image

mrbrianevans avatar Oct 14 '22 21:10 mrbrianevans

The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/3255261581

github-actions[bot] avatar Oct 15 '22 10:10 github-actions[bot]

Made some test data and this is what the graph looks like: image

Perf

The performance of calculating the buckets when the leaderboard is updated: (using my test data set of ~50,000 users)

system_lb_update_english_time_60   "Aggregate 1.078039699971676s, loop 0.002202499985694885s, insert 2.367039000034332s, index 0.24052349996566771s, histogram 0.005574600040912628"

Only for comparison purposes, ignore absolute values. Takes 20x less time to calculate histogram buckets than to aggregate, so performance shouldn't be a problem.

I think this feature is ready to be merged, unless there are any requests for changes?

mrbrianevans avatar Oct 15 '22 14:10 mrbrianevans

Thanks @Bruception for the feedback, I've implemented those points (except for the route change discussed on discord).

mrbrianevans avatar Oct 17 '22 08:10 mrbrianevans

Looking good. Things left to do:

  • [ ] Rename endpoint, rename dal and controller files
  • [ ] Add an endpoint which gets the typing stats (started, completed, time typing)
  • [ ] Add a section above the about section, call it stats
  • [ ] Display tests started, completed, time typing in hours (3 columns)
  • [ ] Display the time 60 histogram below the stats
  • [ ] Make sure the about page is responsive (currently the histogram is causing an overflow)

Miodec avatar Oct 17 '22 09:10 Miodec

The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/3266759160

github-actions[bot] avatar Oct 17 '22 16:10 github-actions[bot]

The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/3266857729

github-actions[bot] avatar Oct 17 '22 16:10 github-actions[bot]

image

Okay @Miodec , I've addressed all of your points. I hope this is what you had in mind, let me know if not or if anything needs changing.

I think it will be quite nice for users to be able to see these stats.

mrbrianevans avatar Oct 17 '22 17:10 mrbrianevans

The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/3267158048

github-actions[bot] avatar Oct 17 '22 17:10 github-actions[bot]