mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(cycle): count the cycle day from the logged start, not the grid window
The day count was the length of the labelled run inside the calendar grid, so the same day read as day 11 over a month and day 23 over three: the run was cut off at the window's edge rather than at the cycle's start. That was a latent contract question while every caller asked for the same ninety days, and it stopped being latent when the month grid began reading its own month, which is thirty days by construction. The verdict now anchors on the period start the record holds and falls back to walking the grid only when no caller supplied one, so the ring's arcs stay grid-derived (they are about what can be drawn) while the day is about what the person logged. The overdue ceiling then measures the real elapsed count too. Covers D-list edge 15, both shapes: a window that clips the run and a window that excludes the cycle start altogether.
This commit is contained in:
1 parent
47d41a13f4
commit
8e3834f38d
2 files changed
+88
-3
No files matched your search
@@ -327,9 +327,21 @@ export function resolveCycleVerdict(
|
||||
}
|
||||
|
||||
const startIdx = findCycleStartIndex(sorted, todayIdx);
|
||||
const cycleStartDate = sorted[startIdx].date;
|
||||
const run = sorted.slice(startIdx, todayIdx + 1);
|
||||
const dayOfCycle = run.length;
|
||||
|
||||
// The day count comes from the logged start when the caller supplied one,
|
||||
// and only falls back to the length of the labelled run when it did not.
|
||||
// The run is bounded by the grid, so counting rows made the answer depend on
|
||||
// how much calendar the caller happened to ask for: the same day reads as
|
||||
// day 11 over a month and day 23 over three. That was latent while every
|
||||
// caller asked for the same ninety days, and stopped being latent when the
|
||||
// month grid started reading its own month. The arcs below stay grid-derived
|
||||
// — they are about what the ring can draw, not about what day it is.
|
||||
const anchoredStart =
|
||||
input.lastPeriodStart && dayDiff(today, input.lastPeriodStart) >= 0
|
||||
? input.lastPeriodStart
|
||||
: sorted[startIdx].date;
|
||||
const cycleStartDate = anchoredStart;
|
||||
const dayOfCycle = dayDiff(today, anchoredStart) + 1;
|
||||
|
||||
// Honest ceiling: once the run overshoots the typical length + grace, the
|
||||
// count reflects the engine's open-ended cycle window, not an observed
|
||||
|
||||
Reference in new issue
Block a user