monkeytype
monkeytype copied to clipboard
Implement streaks
Hi,
I've added the concept of streaks.
I updated the profile page to show the user's current streak.

The streak will also affect the XP bonus, the larger the streak, the higher bonus.
I have updated the XP modifier to add the log10 calculation of the streak. That means that a streak below 10 days will increase the modifier with 0.x, a streak below 100 will increase the modifier with 1.x, a streak below 1000 will increase the modifier with 2.x etc.
I think the implementation could be better. Installing that package and calculating the streak on both the frontend and backend seems a bit wasteful.
Instead I propose a new user endpoint on the backend that just gets the streak of the user.
@Ferotiq I now store the streak on the user. The expensive calculation is only necessary once, after that the streak is calculated based on the last result.
@Ferotiq Would you like to take an additional look, after my latest changes?
I think it's fine to just avoid the init calculation and ignore any streaks before this feature is introduced
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2818005686
@Miodec Thanks, I have removed the code performing the initial calculation.
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2818658674
@Miodec The tests should also be passing now :) I was unfortunate to hit the code coverage threshold with 39.73% code coverage 😂
@Miodec Would you like to re-activate the tests?
@Miodec @Ferotiq Will one of you take an additional look when you have time? :)
Why close?
Mistake
I don't like how you're getting the whole user doc everytime the profile is viewed. Plus it looks like if you view someone else's profile, their streak data will be put into the local db snapshot.
You should get the streak data from the profile endpoint. As for updating local db snapshot - add the streak data to the result adding response.
Also, isToday and isYesterday should probably be placed in misc.ts
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2832202634
This PR is stale. Please trigger a re-run of the PR check action.
Waiting for you to address the issues raised by me and Bruce
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2909824689
@typermonkeyuser any updates?
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989112343
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989121485
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989197900
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989199062
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989225400
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989363964
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989407426
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989441804
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989477713
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989485109
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989532102
The PR check action failed. Please review the logs and make the necessary changes. https://github.com/monkeytypegame/monkeytype/actions/runs/2989566082