feat: add productivity score for categories
Rebased and salvaged #162
Shouldn't require any changes to backend code.
Tasks
- [ ] Review what would make the best UX from previous discussions
- [ ] How long you need to engage in a 1 point activity to get 1 point? (an hour?)
- [x] Add computation of score for period
-
totalScore = 0 for event in events: totalScore += event.duration * get_score(event.category, allCategories) return totalScore / (60 * 60) # from score-seconds to score-hours
-
- [x] Add visualization (just a number of the total score today?)
- [x] Make sure score is inherited correctly
- [ ] What should scores be for the default categories?
Codecov Report
Patch coverage has no change and project coverage change: -0.32 :warning:
Comparison is base (
af12a54) 24.53% compared to head (ff9ecab) 24.22%.
Additional details and impacted files
@@ Coverage Diff @@
## master #258 +/- ##
==========================================
- Coverage 24.53% 24.22% -0.32%
==========================================
Files 27 27
Lines 1520 1540 +20
Branches 248 251 +3
==========================================
Hits 373 373
- Misses 1122 1142 +20
Partials 25 25
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/main.js | 0.00% <0.00%> (ø) |
|
| src/stores/activity.ts | 30.24% <0.00%> (-0.78%) |
:arrow_down: |
| src/stores/categories.ts | 50.00% <0.00%> (-5.56%) |
:arrow_down: |
| src/util/classes.ts | 81.18% <ø> (ø) |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
How long you need to engage in a 1 point activity to get 1 point? (an hour?)
I never thought of it in that way at all.
Since you can do productive things outside of using your computer, to me it's more important to give a score of how productive you are on average rather than a sum of all your productive time. So rather than to just say a number "Todays productivity score was 800", I had always imagined a scale from -1 to 1 which could in text say "Very productive" if it's for example above 0.7 or something.
@johan-bjareholt I think the current way is essentially identical to your way, except that the final value is unbounded. The current formula essentially returns a score-weighted average, where the scores can be both negative and positive depending on what the scores the user sets, so user more productive -> total score increases, user unproductive -> total score decreases.
If we want to bound the value, we can pass it through a tanh(total_score) function, which will map the values to [-1,1].

I added a really quick-n-dirty visualization in the latest commit:

Finally merging this. The remaining tasks will have to wait for another day.