monkeytype icon indicating copy to clipboard operation
monkeytype copied to clipboard

Inconsistent dates on the new activity graph due the timezones

Open FloatingComet62 opened this issue 2 years ago • 3 comments

Did you clear cache before opening an issue?

  • [X] I have cleared my cache

Is there an existing issue for this?

  • [X] I have searched the existing issues

Does the issue happen when logged in?

Yes

Does the issue happen when logged out?

No

Does the issue happen in incognito mode when logged in?

Yes

Does the issue happen in incognito mode when logged out?

No

Account name

FloatingComet62

Account config

{"theme":"matrix","themeLight":"serika","themeDark":"serika_dark","autoSwitchTheme":false,"customTheme":false,"customThemeColors":["#323437","#e2b714","#e2b714","#646669","#2c2e31","#d1d0c5","#ca4754","#7e2a33","#ca4754","#7e2a33"],"favThemes":[],"showKeyTips":true,"smoothCaret":"medium","quickRestart":"tab","punctuation":false,"numbers":false,"words":10,"time":15,"mode":"words","quoteLength":[0,1,2,3],"language":"english","fontSize":2,"freedomMode":false,"difficulty":"normal","blindMode":false,"quickEnd":false,"caretStyle":"default","paceCaretStyle":"default","flipTestColors":false,"layout":"default","funbox":"none","confidenceMode":"off","indicateTypos":"off","timerStyle":"mini","liveSpeedStyle":"mini","liveAccStyle":"mini","liveBurstStyle":"mini","colorfulMode":false,"randomTheme":"off","timerColor":"main","timerOpacity":"1","stopOnError":"letter","showAllLines":false,"keymapMode":"off","keymapStyle":"staggered","keymapLegendStyle":"lowercase","keymapLayout":"overrideSync","keymapShowTopRow":"layout","fontFamily":"Comfortaa","smoothLineScroll":false,"alwaysShowDecimalPlaces":false,"alwaysShowWordsHistory":true,"singleListCommandLine":"on","capsLockWarning":true,"playSoundOnError":"1","playSoundOnClick":"1","soundVolume":"1.0","startGraphsAtZero":true,"showOutOfFocusWarning":true,"paceCaret":"off","paceCaretCustomSpeed":100,"repeatedPace":true,"accountChart":["on","on","on","on"],"minWpm":"custom","minWpmCustomSpeed":100,"highlightMode":"letter","typingSpeedUnit":"wpm","ads":"off","hideExtraLetters":false,"strictSpace":false,"minAcc":"custom","minAccCustom":95,"monkey":false,"repeatQuotes":"off","oppositeShiftMode":"off","customBackground":"","customBackgroundSize":"cover","customBackgroundFilter":[0,1,1,1,1],"customLayoutfluid":"qwerty#dvorak#colemak","monkeyPowerLevel":"off","minBurst":"off","minBurstCustomSpeed":100,"burstHeatmap":true,"britishEnglish":false,"lazyMode":false,"showAverage":"off","tapeMode":"off","maxLineWidth":0}

Current Behavior

Consider a client which is 1 hour ahead of the server, and the client does a typing test at 00:01 Jan 1. When they go to the user page, they see that the the activity graph says "no activity on 1 Jan", because for the server it's still Dec 31. Whereas when we look at the list of races at the bottom of the user page, the date of the most recent race will be Jan 1.

Here is my scenario, with 00:11 24 May 2024 Screenshot 2024-05-24 001340 Screenshot 2024-05-24 001405

Expected Behavior

The activity graph should say "1 test on 1 Jan"

Steps To Reproduce

  1. Be in a timezone ahead of the server
  2. Do a typing test after your midnight, but before the server's midnight
  3. Go to the user's page and compare the activity graph and the list of tests

Environment

  • OS: Windows 11
  • Browser: Google Chrome
  • Browser Version: 125.0.6422.76 (Official Build) (64-bit) (cohort: Stable)

Anything else?

I think I figured out how to fix this issue. The activity graph should only fetch data for the tests older than 48 hours (number pulled out of thin air, probably can be reduced). And calculate for the tests younger than 48 hours on the client side.

FloatingComet62 avatar May 24 '24 05:05 FloatingComet62

I am currently looking at code, trying to find the backend endpoint to understand how you handle the activity graph, but in the mean while I realized that the original "fix" i suggest would make tests shift a day back after 48 hours.

(if you just have a counter, which seems like the best way to make a graph like this, then it will be even more easier to handle this)

FloatingComet62 avatar May 24 '24 07:05 FloatingComet62

Looks like you do use a counter! [ backend\src\dal\user.ts\incrementTestActivity() (Line 609) ]

the only reasonable solution i can think of is to use the function getDayOfYear on the client side

FloatingComet62 avatar May 24 '24 07:05 FloatingComet62

We decided to not worry about timezones and just base it off of UTC. Handling timezones is just too much of a pain. (this is also what github does for their graph)

Miodec avatar May 24 '24 10:05 Miodec