kinabalu / obsidian-word-sprint

Obsidian Word Sprint plugin
MIT License
41 stars 6 forks source link

Average Words per minute and total time not writing are not reporting accurately #5

Closed kinabalu closed 2 years ago

leethobbit commented 2 years ago

I may have some time this weekend, I will try to troubleshoot the code so you have a second set of eyes on it.

MalignantCarp commented 2 years ago

Average WPM looks to be fixed in the latest, but the modal display could probably include one or two decimal points for average words per minute:

image

MalignantCarp commented 2 years ago

I think the totalTimeNotWriting should be correct in most cases. If I understand the code correctly, the only thing that needs to be added to fix any incorrect numbers is to calculate additional time not writing at the end of the sprint and add that. Since it only appears to be calculated on typing events, if the writer isn't typing at the very end of the sprint, you are not adding that time to the total. I suspect if you started a 1 minute sprint and let it run to the end, it should say 0 time not writing.

MalignantCarp commented 2 years ago

The totalTimeNotWriting bug is a combination of 3 issues: 1) The typing update where totalTimeNotWriting is incremented can be called more than once per second; it's called as often as you type, so it's adding bits and pieces and potentially could be adding the same bit of time (I'm not positive on that). 2) Despite talking about seconds, it's all in milliseconds, and honestly this can easily be more granular. I'd recommend a minimum of 1 second before it counts (so nothing < 1000 ms should be added. From my own preference, I think the yellow warning timeout should make the determination. If it's less than the yellow warning timeout, there's no need to consider the person as not writing. 3) When the sprint ends and when it is cancelled, the totalTimeNotWriting is not updated.

kinabalu commented 2 years ago

looks like with @MalignantCarp latest fixes which are released tis is all fixed. please re-open if it regresses