follow-up(statistics): P3 cleanups from #92 review (period KPIs and entrances) #99

Closed
opened 2026-09-25 12:14:46 +00:00 by gabogg · 1 comment
Owner

Follow-ups from the pass-2 review of #92 (comment on #92). All P3; no P1/P2 remained. The partial-period design question is split out into its own needs-triage issue.

Standards

  • One trusted-multiplier helper. The daily series (bounds.end, is not None) and get_calibration_audit (bounds.next_start, truthiness) now select the cycle multiplier differently; a trusted 0.0 is accepted by one and not the other. Extract _trusted_cycle_multiplier(day, bounds, default).
  • Dayparts dwell multiplier. get_dwell_dayparts_async uses active_exit_multiplier while the daily series uses the cycle's trusted multiplier, so one day can show two dwell values.
  • Comparison logic in three places. The partial-period / zero-reference rule lives in statistics_visitor_comparison_async and twice inline in the entrances route. One compare_visitors(current, reference, partial) factory.
  • Previous-month quality queried twice in get_statistics_summary_async.
  • previous_month_daily_average_reason: str | None should use ComparisonReason.
  • Optional narrowing. year_quality is PeriodQuality | None but read as .partial without narrowing.
  • Repeated switches on granularity inside get_statistics_summary_async.
  • Controller try/except duplicated (ValueError → 422, LookupError → 404) across both routes.
  • Names. busiest_day/best_day hold the same value; old/prior/top in the entrances loop; EntranceStatistics.zone_name conflicts with CONTEXT.md's "Zone" avoid-list.

Spec

  • Test gaps. Untested: NO_REFERENCE_DATA; period dwell weighted by open_window_visitors; PARTIAL_PERIOD on the entrances route; skipping zero-event cameras; the < end_epoch bound on is_new.
  • Unaligned-week test uses a future date, so its 422 doesn't isolate the alignment check. Use a past Tuesday.

🤖 Generated with Claude Code

Follow-ups from the pass-2 review of #92 (comment on #92). All P3; no P1/P2 remained. The partial-period design question is split out into its own `needs-triage` issue. ## Standards - [ ] **One trusted-multiplier helper.** The daily series (`bounds.end`, `is not None`) and `get_calibration_audit` (`bounds.next_start`, truthiness) now select the cycle multiplier differently; a trusted `0.0` is accepted by one and not the other. Extract `_trusted_cycle_multiplier(day, bounds, default)`. - [ ] **Dayparts dwell multiplier.** `get_dwell_dayparts_async` uses `active_exit_multiplier` while the daily series uses the cycle's trusted multiplier, so one day can show two dwell values. - [ ] **Comparison logic in three places.** The partial-period / zero-reference rule lives in `statistics_visitor_comparison_async` and twice inline in the entrances route. One `compare_visitors(current, reference, partial)` factory. - [ ] **Previous-month quality queried twice** in `get_statistics_summary_async`. - [ ] **`previous_month_daily_average_reason: str | None`** should use `ComparisonReason`. - [ ] **Optional narrowing.** `year_quality` is `PeriodQuality | None` but read as `.partial` without narrowing. - [ ] **Repeated switches on `granularity`** inside `get_statistics_summary_async`. - [ ] **Controller try/except duplicated** (`ValueError → 422`, `LookupError → 404`) across both routes. - [ ] **Names.** `busiest_day`/`best_day` hold the same value; `old`/`prior`/`top` in the entrances loop; `EntranceStatistics.zone_name` conflicts with CONTEXT.md's "Zone" avoid-list. ## Spec - [ ] **Test gaps.** Untested: `NO_REFERENCE_DATA`; period dwell weighted by `open_window_visitors`; `PARTIAL_PERIOD` on the entrances route; skipping zero-event cameras; the `< end_epoch` bound on `is_new`. - [ ] **Unaligned-week test** uses a future date, so its 422 doesn't isolate the alignment check. Use a past Tuesday. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

The daypart dwell multiplier and the trusted-multiplier helper moved to #106. The rest stays here.

🤖 Generated with Claude Code

The daypart dwell multiplier and the trusted-multiplier helper moved to #106. The rest stays here. 🤖 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#99
No description provided.