follow-up(statistics): P3 cleanups from #89 review (periods and daily series) #96

Closed
opened 2026-09-25 12:14:43 +00:00 by gabogg · 2 comments
Owner

Follow-ups from the pass-2 review of #89 (comment on #89). All P3; the P2s were fixed in ca30e17 before merge.

Standards

  • Daily series query count. get_statistics_daily_series_async still runs several queries per day (flow, calibration log, schedule, peak, open-window counts, average). Quality is now one range read (ca30e17); the rest could be batched too. A 62-day range still costs a few hundred queries.
  • Repeated switches on granularity. statistics_period_end, previous_statistics_period and latest_closed_statistics_period (app/services/analytics_service.py) each switch on granularity; one per-granularity strategy map would keep them together.
  • daily_reset_time default repeated. cfg.get("daily_reset_time", "04:00") appears in several statistics methods; occupancy_manager.get_daily_reset_time_async() already exists.
  • Untyped repository returns. get_counted_day_flow_async returns (int, int, bool) and get_counted_cycle_quality_range_async returns list[dict[str, Any]] read by string key. Use a NamedTuple/TypedDict. The cycles: list[tuple[str, float, float]] argument is an anonymous triple that must be passed sorted.

Spec

  • Per-day excluded flag. The picker reports excluded_days, but DailyStatistics has no per-day excluded flag, so the deck can't show which day was excluded (not required by #84).
  • Test gaps. Untested: gap_estimated_days > 0 on the picker, a day with is_holiday: true, occupancy_definition_cutover_at on the daily series, and the historical trusted-multiplier path (the fixture uses is_trusted=0 and IN-only events). The dwell check is only is not None.

🤖 Generated with Claude Code

Follow-ups from the pass-2 review of #89 (comment on #89). All P3; the P2s were fixed in ca30e17 before merge. ## Standards - [ ] **Daily series query count.** `get_statistics_daily_series_async` still runs several queries per day (flow, calibration log, schedule, peak, open-window counts, average). Quality is now one range read (ca30e17); the rest could be batched too. A 62-day range still costs a few hundred queries. - [ ] **Repeated switches on `granularity`.** `statistics_period_end`, `previous_statistics_period` and `latest_closed_statistics_period` (`app/services/analytics_service.py`) each switch on granularity; one per-granularity strategy map would keep them together. - [ ] **`daily_reset_time` default repeated.** `cfg.get("daily_reset_time", "04:00")` appears in several statistics methods; `occupancy_manager.get_daily_reset_time_async()` already exists. - [ ] **Untyped repository returns.** `get_counted_day_flow_async` returns `(int, int, bool)` and `get_counted_cycle_quality_range_async` returns `list[dict[str, Any]]` read by string key. Use a `NamedTuple`/TypedDict. The `cycles: list[tuple[str, float, float]]` argument is an anonymous triple that must be passed sorted. ## Spec - [ ] **Per-day excluded flag.** The picker reports `excluded_days`, but `DailyStatistics` has no per-day `excluded` flag, so the deck can't show which day was excluded (not required by #84). - [ ] **Test gaps.** Untested: `gap_estimated_days > 0` on the picker, a day with `is_holiday: true`, `occupancy_definition_cutover_at` on the daily series, and the historical trusted-multiplier path (the fixture uses `is_trusted=0` and IN-only events). The dwell check is only `is not None`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

The per-day excluded flag moved to #106 (needed by the deck's quality marker). The rest stays here.

🤖 Generated with Claude Code

The per-day `excluded` flag moved to #106 (needed by the deck's quality marker). The rest stays here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Resolved by #167 (merged 2026-10-02, 103157c). Every item is done except per-day peak and average Riemann integration, which is tracked in #203. Third-pass leftovers are tracked in #219.

Resolved by #167 (merged 2026-10-02, `103157c`). Every item is done except per-day peak and average Riemann integration, which is tracked in #203. Third-pass leftovers are tracked in #219.
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#96
No description provided.