feat: improve webhook filtering, worker status startup handling, and timestamp parsing
- Skip half_hour_report events from webhook posts in people_flow - Handle pre-existing stale worker status files during startup gracefully - Make store_dwell_alert timestamp parsing robust against invalid/empty values - Update lessons learned and todo documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import json
|
||||
from src.people_flow.webhook import dispatch_json_event
|
||||
|
||||
|
||||
def test_dispatch_json_event_omits_tracks_from_webhook_but_keeps_local_log(
|
||||
def test_dispatch_json_event_does_not_post_half_hour_report_but_keeps_local_log(
|
||||
tmp_path, monkeypatch
|
||||
):
|
||||
sent: dict[str, object] = {}
|
||||
@@ -44,9 +44,4 @@ def test_dispatch_json_event_omits_tracks_from_webhook_but_keeps_local_log(
|
||||
|
||||
lines = output.read_text(encoding="utf-8").splitlines()
|
||||
assert json.loads(lines[0]) == payload
|
||||
assert sent["url"] == "https://example.test/webhook"
|
||||
assert sent["timeout"] == 7.5
|
||||
assert sent["payload"] == {
|
||||
"event": "half_hour_report",
|
||||
"total_people": 3,
|
||||
}
|
||||
assert sent == {}
|
||||
|
||||
@@ -99,3 +99,29 @@ def test_worker_status_stall_reason_reports_missing_and_stale_status(tmp_path: P
|
||||
assert "status=missing" not in reason
|
||||
assert "phase=tracking_frame" in reason
|
||||
assert "age_seconds=200.0" in reason
|
||||
|
||||
|
||||
def test_worker_status_stall_reason_ignores_preexisting_stale_file_during_startup(
|
||||
tmp_path: Path,
|
||||
):
|
||||
status_path = tmp_path / "worker_status.json"
|
||||
write_worker_status(
|
||||
status_path,
|
||||
"waiting_to_reconnect",
|
||||
source="rtsp://camera/stream",
|
||||
window_index=0,
|
||||
frame_index=0,
|
||||
last_processed_at=None,
|
||||
note="open_failed",
|
||||
)
|
||||
os.utime(status_path, (100.0, 100.0))
|
||||
|
||||
assert (
|
||||
worker_status_stall_reason(
|
||||
status_path,
|
||||
started_at=250.0,
|
||||
max_age_seconds=180.0,
|
||||
now=300.0,
|
||||
)
|
||||
is None
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user