3.8 KiB
02 — Show work-sequence and time-off-period lengths
What to build: The statistics popup shows average and longest working stretches, average and longest complete breaks, and non-working-day gain, using the calculated plan's shared calendar semantics.
Blocked by:
- 01 — Open plan statistics for calculated leave usage.
- #62 — Optimiser les périodes de repos autour des jours déclarés, which establishes time-off periods and work sequences that include declared non-working days.
Status: ready-for-agent
Gitea: #66
Source: the agreed Plan Statistics Popup spec for #3 and #29, including #7. The existing longest work-sequence metric from #28 is reused. Follow the domain glossary and ADRs 0004, 0006, and 0007.
- Add five labelled metrics: non-working-day gain, average work-sequence length, longest work-sequence length, average time-off period length, and longest time-off period length. Work lengths use working days; break lengths use calendar days.
- The work-sequence average includes every non-empty sequence inside the submitted horizon, including both edges. Weekends and French public holidays neither count nor split a sequence; leave placements and declared non-working days interrupt it. Consecutive days off introduce no zero-length samples.
- Sequences of 10, 5, and 15 working days produce an average of 10 and a longest length of 15. Fractional averages remain representable and calculations do not prematurely round the underlying values.
- Break statistics use full canonical time-off periods, including merged declarations and placements and contiguous non-working dates immediately outside the horizon. Friday and Monday off around a holiday-free weekend produce one 4-calendar-day period. A declared Friday with no new placements produces a 3-day Friday–Sunday period.
- Non-working-day gain counts distinct weekend and public-holiday dates in these periods. A weekend public holiday contributes once; a declared day does not itself become additional weekend or holiday gain.
- Saved declarations outside the horizon do not inflate in-horizon work counts or create isolated out-of-horizon periods. Adjacent declarations may extend a period anchored inside the horizon under the shared calendar contract.
- Empty samples remain distinguishable from measured zero. A valid plan without work sequences retains a longest work-sequence length of 0; missing average samples and a missing longest time-off period retain an explicit empty data state.
- All five figures inherit the popup's snapshot, trace independence, and partial-plan behavior. Any new outcome facts survive direct planning, worker transport, and retained-plan checkpoints and describe the actual displayed plan.
- Behavior tests cover fractional means, both horizon edges, contiguous days off, intervening weekends and holidays, declarations without new placements, merged periods, adjacent context dates, and empty samples. Check rendered units and values, complete and retained partial outcomes, and the repository's existing tests, lint, formatting, type checks, and production build.
Reuse #62's calendar and period definitions rather than adding a conflicting calendar model. These descriptive metrics do not change the planning objective order.
Proposed presentation default, not explicitly confirmed: show "—" for an average without samples and for the longest time-off period when none exists. Decimal precision follows existing presentation conventions; it does not change the underlying metric.