feat(awooop): summarize callback capture in runs list
This commit is contained in:
@@ -1078,6 +1078,24 @@ def _callback_reply_evidence_capture_status(
|
||||
}
|
||||
|
||||
|
||||
def _callback_reply_capture_status_from_outbound(
|
||||
row: AwoooPOutboundMessage,
|
||||
callback_reply: Mapping[str, Any],
|
||||
) -> dict[str, Any]:
|
||||
"""Build capture status directly from one outbound source envelope."""
|
||||
source_envelope = _as_dict(row.source_envelope)
|
||||
return _callback_reply_evidence_capture_status(
|
||||
callback_reply=callback_reply,
|
||||
persisted_awooop_status_chain=(
|
||||
_as_dict(source_envelope.get("awooop_status_chain")) or None
|
||||
),
|
||||
persisted_km_stale_completion_summary=(
|
||||
_as_dict(source_envelope.get("km_stale_completion_summary")) or None
|
||||
),
|
||||
event_at=row.sent_at or row.queued_at,
|
||||
)
|
||||
|
||||
|
||||
def _callback_reply_event_item(row: Mapping[str, Any]) -> dict[str, Any]:
|
||||
"""Convert one callback reply outbound row into a read-only evidence item."""
|
||||
callback_reply = _as_dict(row.get("callback_reply"))
|
||||
@@ -1481,6 +1499,13 @@ def _run_callback_reply_summary(
|
||||
"latest_incident_id": None,
|
||||
"latest_at": None,
|
||||
"latest_provider_message_id": None,
|
||||
"capture_status": "no_callback",
|
||||
"capture_captured": 0,
|
||||
"capture_partial": 0,
|
||||
"capture_not_captured": 0,
|
||||
"latest_capture_status": None,
|
||||
"latest_capture_missing": [],
|
||||
"latest_capture_next_action": None,
|
||||
}
|
||||
|
||||
sorted_rows = sorted(
|
||||
@@ -1496,6 +1521,26 @@ def _run_callback_reply_summary(
|
||||
failed = statuses.count("callback_reply_failed")
|
||||
latest_status = str(latest_callback.get("status") or "")
|
||||
summary_status = _callback_reply_public_status(latest_callback)
|
||||
capture_rows = [
|
||||
_callback_reply_capture_status_from_outbound(row, callback)
|
||||
for row, callback in sorted_rows
|
||||
]
|
||||
capture_statuses = [
|
||||
str(capture.get("status") or "observed")
|
||||
for capture in capture_rows
|
||||
]
|
||||
capture_not_captured = capture_statuses.count("not_captured")
|
||||
capture_partial = capture_statuses.count("partial")
|
||||
capture_captured = capture_statuses.count("captured")
|
||||
latest_capture = capture_rows[0] if capture_rows else {}
|
||||
if capture_not_captured > 0:
|
||||
capture_status = "not_captured"
|
||||
elif capture_partial > 0:
|
||||
capture_status = "partial"
|
||||
elif capture_captured > 0 and capture_captured == len(capture_rows):
|
||||
capture_status = "captured"
|
||||
else:
|
||||
capture_status = "observed"
|
||||
|
||||
return {
|
||||
"schema_version": "awooop_run_callback_reply_summary_v1",
|
||||
@@ -1511,6 +1556,13 @@ def _run_callback_reply_summary(
|
||||
"latest_incident_id": latest_callback.get("incident_id"),
|
||||
"latest_at": latest_row.sent_at or latest_row.queued_at,
|
||||
"latest_provider_message_id": latest_row.provider_message_id,
|
||||
"capture_status": capture_status,
|
||||
"capture_captured": capture_captured,
|
||||
"capture_partial": capture_partial,
|
||||
"capture_not_captured": capture_not_captured,
|
||||
"latest_capture_status": latest_capture.get("status"),
|
||||
"latest_capture_missing": latest_capture.get("missing") or [],
|
||||
"latest_capture_next_action": latest_capture.get("next_action"),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user