feat(awooop): show callback gap freshness
All checks were successful
CD Pipeline / tests (push) Successful in 1m32s
Code Review / ai-code-review (push) Successful in 12s
CD Pipeline / build-and-deploy (push) Successful in 3m29s
CD Pipeline / post-deploy-checks (push) Successful in 1m20s

This commit is contained in:
Your Name
2026-05-25 21:20:10 +08:00
parent 101b08946a
commit dcde86c7f9
7 changed files with 236 additions and 17 deletions

View File

@@ -120,7 +120,13 @@ class CallbackReplyAuditSummary(BaseModel):
outbound_incident_ref_total: int
outbound_reply_markup_total: int = 0
outbound_reply_markup_missing_incident_ref_total: int = 0
outbound_reply_markup_missing_incident_ref_recent_1h_total: int = 0
outbound_reply_markup_missing_incident_ref_recent_24h_total: int = 0
outbound_reply_markup_missing_incident_ref_latest_sent_at: datetime | None = None
outbound_reply_markup_missing_trace_ref_total: int = 0
outbound_reply_markup_missing_trace_ref_recent_1h_total: int = 0
outbound_reply_markup_missing_trace_ref_recent_24h_total: int = 0
outbound_reply_markup_missing_trace_ref_latest_sent_at: datetime | None = None
outbound_reply_markup_missing_incident_ref_top_prefixes: list[
OutboundReplyMarkupGapPrefix
] = Field(default_factory=list)

View File

@@ -527,10 +527,47 @@ async def _fetch_callback_reply_audit_summary(
'[]'::jsonb
) = '[]'::jsonb
) AS outbound_reply_markup_missing_incident_ref_total,
COUNT(*) FILTER (
WHERE source_envelope #>> '{reply_markup,present}' = 'true'
AND COALESCE(
source_envelope #> '{source_refs,incident_ids}',
'[]'::jsonb
) = '[]'::jsonb
AND COALESCE(sent_at, queued_at) >= NOW() - INTERVAL '1 hour'
) AS outbound_reply_markup_missing_incident_ref_recent_1h_total,
COUNT(*) FILTER (
WHERE source_envelope #>> '{reply_markup,present}' = 'true'
AND COALESCE(
source_envelope #> '{source_refs,incident_ids}',
'[]'::jsonb
) = '[]'::jsonb
AND COALESCE(sent_at, queued_at) >= NOW() - INTERVAL '24 hours'
) AS outbound_reply_markup_missing_incident_ref_recent_24h_total,
MAX(COALESCE(sent_at, queued_at)) FILTER (
WHERE source_envelope #>> '{reply_markup,present}' = 'true'
AND COALESCE(
source_envelope #> '{source_refs,incident_ids}',
'[]'::jsonb
) = '[]'::jsonb
) AS outbound_reply_markup_missing_incident_ref_latest_sent_at,
COUNT(*) FILTER (
WHERE source_envelope #>> '{reply_markup,present}' = 'true'
AND NOT has_trace_ref
) AS outbound_reply_markup_missing_trace_ref_total,
COUNT(*) FILTER (
WHERE source_envelope #>> '{reply_markup,present}' = 'true'
AND NOT has_trace_ref
AND COALESCE(sent_at, queued_at) >= NOW() - INTERVAL '1 hour'
) AS outbound_reply_markup_missing_trace_ref_recent_1h_total,
COUNT(*) FILTER (
WHERE source_envelope #>> '{reply_markup,present}' = 'true'
AND NOT has_trace_ref
AND COALESCE(sent_at, queued_at) >= NOW() - INTERVAL '24 hours'
) AS outbound_reply_markup_missing_trace_ref_recent_24h_total,
MAX(COALESCE(sent_at, queued_at)) FILTER (
WHERE source_envelope #>> '{reply_markup,present}' = 'true'
AND NOT has_trace_ref
) AS outbound_reply_markup_missing_trace_ref_latest_sent_at,
COALESCE((
SELECT jsonb_agg(
jsonb_build_object(
@@ -739,9 +776,27 @@ def _callback_reply_audit_summary_from_row(
"outbound_reply_markup_missing_incident_ref_total": _safe_int(
row.get("outbound_reply_markup_missing_incident_ref_total")
),
"outbound_reply_markup_missing_incident_ref_recent_1h_total": _safe_int(
row.get("outbound_reply_markup_missing_incident_ref_recent_1h_total")
),
"outbound_reply_markup_missing_incident_ref_recent_24h_total": _safe_int(
row.get("outbound_reply_markup_missing_incident_ref_recent_24h_total")
),
"outbound_reply_markup_missing_incident_ref_latest_sent_at": row.get(
"outbound_reply_markup_missing_incident_ref_latest_sent_at"
),
"outbound_reply_markup_missing_trace_ref_total": _safe_int(
row.get("outbound_reply_markup_missing_trace_ref_total")
),
"outbound_reply_markup_missing_trace_ref_recent_1h_total": _safe_int(
row.get("outbound_reply_markup_missing_trace_ref_recent_1h_total")
),
"outbound_reply_markup_missing_trace_ref_recent_24h_total": _safe_int(
row.get("outbound_reply_markup_missing_trace_ref_recent_24h_total")
),
"outbound_reply_markup_missing_trace_ref_latest_sent_at": row.get(
"outbound_reply_markup_missing_trace_ref_latest_sent_at"
),
"outbound_reply_markup_missing_incident_ref_top_prefixes": (
top_missing_prefixes
),