feat(statistics): present approved historical flow and baselines #172
No reviewers
Labels
No labels
blocked
bug
enhancement
high-priority
low-priority
needs-info
needs-triage
ready-for-agent
ready-for-human
referenced
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gabogg/hikcentral!172
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/historical-flow-statistics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Draft for #165: the statistics deck reads approved historical hourly aggregates alongside local data, without double-counting.
It was split out of #166. Specification: #165 and the historical-flow RFC. Holiday/event presentation coordinates with #161.
Stacked on
feat/historical-flow-publication(#164 draft). Only a placeholder commit is on this branch; implementation has not started.Architectural impact (planned)
Verification
scripts/check_docs.py, full pytest.Checklist
Issues closed on merge
Closes #165
🤖 Generated with Claude Code
WIP: feat(statistics): present approved historical flow and baselinesto feat(statistics): present approved historical flow and baselinesMarked
blocked, at the maintainer's request (2026-10-02). The review pass waits until this PR's base is real:master. This PR builds on #178's code, so reviewing it first would risk findings going stale if #178 changes in review.Unblock once #178 has merged,
masterhas been carried up the stack, and #171 has real code. This PR then gets its first review pass.Current state: the branch includes
masteras ofb48940e, and its diff against #171 is 14 files (+1464/−90).🤖 Generated with Claude Code
Unblocked: #178 merged (
b64e805), and master is merged into #170 and #171. Mergingorigin/feat/historical-flow-publicationinto this branch conflicts instatistics_controller.py(1 hunk),occupancy_repository.py(2) andanalytics_service.py(3). #178's holiday and event context overlaps the historical-flow statistics here. That needs a domain decision, so I aborted the merge and left it to this PR's agent.Merge Conflict Resolution:
origin/feat/historical-flow-publicationintofeat/historical-flow-statisticsMerged
origin/feat/historical-flow-publication(incorporating #178 holiday and event context into investor analytics) intofeat/historical-flow-statistics. All conflicts were resolved preserving both domain features:app/controllers/statistics_controller.py(1 hunk)get_presenter_hourly_series, retained bothclosed_day_config_async(day)configuration resolution (cfg) from #178 and the integer castbucket_minutes=int(bucket_minutes)from #165, passing both toanalytics_service.get_hourly_timeseries_async.app/db/occupancy_repository.py(2 hunks)get_counted_camera_flow_async): Maintained the approved camera hours CTE resolution from #165 while adoptingg.resource_group_name AS camera_group(from #168/#178) instead of the obsoletec.zone_nameacross both the local-only and resolved-CTE branches.get_trusted_calibration_history_async): Retained the dynamic reset time resolution and timed-event date exclusion from #178, updated holiday identification to queryoccupancy_business_day_schedules WHERE is_holiday = 1as the single source of truth, and preserved strict calibration exclusion for imported/mixed days viacycle_date NOT IN (SELECT business_day FROM flow_history_approved_days).app/services/analytics_service.py(3 hunks)get_statistics_summary_async): Kept the structured summary comparison variables initialization from #178 while safely handling historical days wherepeak_people_insideisNone.get_statistics_daily_series_async): Combined the holiday calendar (sched = calendar.schedule_for(day)) and event summaries from #178 with historical flow day resolution (app_day,is_hourly_source,source,coverage, andget_counted_day_flow_async). Approved historical days now carry full holiday and event context identically to local days.get_dwell_dayparts_async): Integrated the approved day check with_compute_dayparts_for_day_async, yieldingDwellDay(date=current_day, dayparts=[], unavailable_reason="HOURLY_AGGREGATE_ONLY")on approved historical days.Verification
test_historical_holiday_day_carries_holiday_and_event_contexttotests/test_historical_flow_statistics.pyverifying that historical days carry holiday and event context in both hourly and daily time-series endpoints.ruff check .passed cleanly (no issues found).ruff format --check .passed cleanly (152 files formatted).python3 scripts/check_docs.pypassed cleanly (42 Markdown files and 89 HTTP operations checked).node --test tests/frontend/*.test.jspassed 100% green (245/245 tests passed).pytestpassed 100% green (565/565 tests passed).Merge Conflict Resolution: PR #171 (feat/historical-flow-publication @
674f266) into feat/historical-flow-statisticsMerged PR #171 (carrying PR #170 curation draft workspace) into feat/historical-flow-statistics. Conflicts were resolved preserving both domain features:
flow_history_curation_drafts,flow_history_curation_days,flow_history_curation_zero_confirmations,flow_history_curation_audit) alongside approved flow tables (#164, #165).ApprovedMonthRecord, curation draft schemas (CurationDaySummary,CurationDraftDetail, etc.), and approved flow records (ApprovedDayRecord,ApprovedHourRecord).publish_approved_month_async,get_approved_day_async, etc.) and Curation Drafts repository methods (create_or_get_curation_draft_async,_compute_day_coverage, etc.).get_trusted_calibration_history_async, preserved pending change reeval logic (#177) and retained strict calibration exclusion for imported/mixed days (AND cycle_date NOT IN (SELECT business_day FROM flow_history_approved_days)).Verification
Merged PR #171 (feat/historical-flow-publication) into #172.
Conflict Resolutions
app/schemas/flow_history.py:ApprovedDayRecordandApprovedHourRecordcontracts. Preserved default values (HISTORICAL_FLOW_SOURCE) and optional fields (id,month,business_day) needed by presentation routes and statistics tests, while incorporatingApprovedDayDetailandApprovedMonthDetail.app/services/occupancy_service.py:is_imported(schedule source),has_imported_flow(imported/mixed flow check), andhas_approved_flowto ensure no approved or imported historical flow can ever update active exit multiplier k.app/db/occupancy_repository.py:get_trusted_calibration_history_conn_asyncand cycle ingress queries, strictly excluded cycles withsource = 'IMPORTED'in schedules and any day inflow_history_approved_daysfrom trusted history.app/db/flow_history_repository.py:get_approved_day_asyncto polymorphically support both single-argument(business_day: str)(used by analytics) and two-argument(month: str, business_day: date)(used by publication/curation), returningApprovedDayDetailwith validateddatetime.datetypes. Retainedpublish_month_async,list_approved_months_async, and range queries.All 632 pytest tests and 250 node tests pass cleanly.
#171 pass-1 fixes are in progress after the #170 pass-2 handoff. Publication now retains snapshots keyed by (month, revision); current readers select MAX(revision) per month, and approved hours retain is_unresolved. I will merge the completed, tested #171 fixes into #172 as requested and adapt any integration conflicts. Please leave the statistics worktree clean for that handoff.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.