feat(investigations): add event impact and work-order feedback flows
Add isolated burst and pollution impact evidence, parallel work-order workflows, persisted notifications and graph updates. Checkpoint current code. Known follow-ups remain for large pollution result previews and graceful geometry failure.
This commit is contained in:
@@ -19,9 +19,20 @@ def current_calibration(document: dict, start: datetime) -> dict | None:
|
||||
return None
|
||||
|
||||
|
||||
def pollution_signal(document: dict, event: dict) -> bool:
|
||||
"""Water-quality measurements have their own incident investigation workflow."""
|
||||
if event.get("category") == "data_quality":
|
||||
return False
|
||||
devices = {item["device_id"]: item.get("device_type") for item in document.get("devices", [])}
|
||||
ids = event.get("device_ids") or next((item.get("device_ids", [])
|
||||
for item in (document.get("config") or {}).get("rules", [])
|
||||
if item["rule_id"] == event.get("rule_id")), [])
|
||||
return bool(ids) and all(devices.get(device) in {"quality", "water_quality"} for device in ids)
|
||||
|
||||
|
||||
def diagnostic_signal(document: dict, event: dict) -> bool:
|
||||
"""Never revive a persisted fixed-percentage event as new diagnosis evidence."""
|
||||
if event.get("category") == "data_quality":
|
||||
if event.get("category") == "data_quality" or pollution_signal(document, event):
|
||||
return False
|
||||
if not weighted_diagnosis(document):
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user