refactor(occupancy): consolidate multiplier re-evaluation pipeline between service and callback #253

Open
opened 2026-10-03 09:12:13 +00:00 by gabogg · 0 comments
Owner

Follow-up for PR #177 (next-day settings activation, #114) addressing pass-4 review finding P3-6:

Scope

In app/services/occupancy_service.py, _reeval_callback (~786) and refresh_active_multiplier_async (~1613) repeat the identical pipeline: seed retrieval, trusted calibration history, sorting, EWMA weighting with gamma 0.25, variance calculation, and configuration persistence.
The two copies have already drifted: one writes last_calibrated_at in the repository while the other writes updated_at.

Acceptance Criteria

  • Consolidate the calculation and persistence pipeline into a shared helper accepting an optional connection parameter (aiosqlite.Connection).
  • Align timestamp column updates across the unified pipeline.

Refs #177, #114.

Follow-up for PR #177 (next-day settings activation, #114) addressing pass-4 review finding P3-6: ### Scope In `app/services/occupancy_service.py`, `_reeval_callback` (~786) and `refresh_active_multiplier_async` (~1613) repeat the identical pipeline: seed retrieval, trusted calibration history, sorting, EWMA weighting with gamma 0.25, variance calculation, and configuration persistence. The two copies have already drifted: one writes `last_calibrated_at` in the repository while the other writes `updated_at`. ### Acceptance Criteria - Consolidate the calculation and persistence pipeline into a shared helper accepting an optional connection parameter (`aiosqlite.Connection`). - Align timestamp column updates across the unified pipeline. Refs #177, #114.
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#253
No description provided.