diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-08 10:11:26 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-08 10:11:26 +0200 |
| commit | e1d80af9899e078f53d2232d2d7ef4680a14bf1c (patch) | |
| tree | f42ac5836de6e21d612017e0b300974a345c57ac /src | |
| parent | e56aeac93bfd8cc05ddf229b7e51939fde41effd (diff) | |
Never-done routines are always at least due
A routine with no completions shows due instead of ok, even right
after creation; ok requires a completion within the current period.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/shared/routine-metrics.test.ts | 4 | ||||
| -rw-r--r-- | src/lib/shared/routine-metrics.ts | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/shared/routine-metrics.test.ts b/src/lib/shared/routine-metrics.test.ts index 1df39ab..ccc06ba 100644 --- a/src/lib/shared/routine-metrics.test.ts +++ b/src/lib/shared/routine-metrics.test.ts @@ -18,10 +18,10 @@ const routine = { }; describe('computeRoutineState', () => { - it('is ok and healthy before the due date', () => { + it('is due when never done, even before the due date', () => { const now = Date.parse(CREATED) + 3 * DAY_MS; const state = computeRoutineState(routine, [], now); - expect(state.status).toBe('ok'); + expect(state.status).toBe('due'); expect(state.overdueDays).toBe(0); expect(state.health).toBe(100); expect(state.dueAt).toBe( diff --git a/src/lib/shared/routine-metrics.ts b/src/lib/shared/routine-metrics.ts index 59413c2..4af989d 100644 --- a/src/lib/shared/routine-metrics.ts +++ b/src/lib/shared/routine-metrics.ts @@ -64,8 +64,10 @@ export function computeRoutineState( // Buckets on overdue time in units of the routine's own frequency: // not due / due now / late (half a period overdue) / very late (a full // period overdue — a weekly routine two weeks old lands here). + // A routine that was never done is always at least due: there is + // something to do, even right after creation. const status: RoutineStatus = - rawRatio < 0 + rawRatio < 0 && lastDoneMs !== null ? 'ok' : overdueRatio < 0.5 ? 'due' |
