follow-up(statistics): P3 cleanups from #116 review (comparison coverage) #120

Closed
opened 2026-09-25 19:17:05 +00:00 by gabogg · 0 comments
Owner

Follow-ups from the pass-2 review of #116 (#104 comparison coverage threshold). All P3; no P1/P2 remained.

Standards

  • compare_visitors / PeriodVisitors.per_day() zero-division guarantee. The comment says the clamped threshold ensures both sides cover at least one day, but PeriodQuality.coverage is 1.0 when business_days == 0, so a fully closed side with no data passes whenever the other side is partial. Callers prevent it today (early CLOSED_PERIOD; entrances skip closed cycles). Guard inside per_day()/compare_visitors (treat covered_days == 0 as non-comparable) or reword the comment to name the callers' guard.
  • Test the clamp: nothing covers an out-of-range stored statistics_min_comparison_coverage row (only the Pydantic rejection is tested).
  • Bare 1.1 in test_threshold_outside_its_bounds_is_rejected; use MIN_COMPARISON_COVERAGE_CEILING + 0.1.
  • Weak test test_threshold_and_its_bounds_are_named only checks the constants are ordered.

Spec

  • Docs precision (docs/api/README.md): "Each comparison states its basis", but basis is null on withheld comparisons and on usual_weekday. Say "each calculated comparison except usual_weekday".
  • Closed Days / exact-threshold test asserts only on the summary, not the entrance comparison.

🤖 Generated with Claude Code

Follow-ups from the pass-2 review of #116 (#104 comparison coverage threshold). All P3; no P1/P2 remained. ## Standards - [ ] **`compare_visitors` / `PeriodVisitors.per_day()` zero-division guarantee.** The comment says the clamped threshold ensures both sides cover at least one day, but `PeriodQuality.coverage` is `1.0` when `business_days == 0`, so a fully closed side with no data passes whenever the other side is partial. Callers prevent it today (early `CLOSED_PERIOD`; entrances skip closed cycles). Guard inside `per_day()`/`compare_visitors` (treat `covered_days == 0` as non-comparable) or reword the comment to name the callers' guard. - [ ] **Test the clamp**: nothing covers an out-of-range stored `statistics_min_comparison_coverage` row (only the Pydantic rejection is tested). - [ ] **Bare `1.1`** in `test_threshold_outside_its_bounds_is_rejected`; use `MIN_COMPARISON_COVERAGE_CEILING + 0.1`. - [ ] **Weak test** `test_threshold_and_its_bounds_are_named` only checks the constants are ordered. ## Spec - [ ] **Docs precision** (`docs/api/README.md`): "Each comparison states its `basis`", but `basis` is null on withheld comparisons and on `usual_weekday`. Say "each calculated comparison except `usual_weekday`". - [ ] **Closed Days / exact-threshold test** asserts only on the summary, not the entrance comparison. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gabogg/hikcentral#120
No description provided.