feat(awooop): show source ref gap recency
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 3m41s
CD Pipeline / post-deploy-checks (push) Successful in 2m13s

This commit is contained in:
Your Name
2026-05-25 20:12:19 +08:00
parent f30405997d
commit a8b7299d1c
7 changed files with 151 additions and 9 deletions

View File

@@ -501,7 +501,10 @@ async def _fetch_callback_reply_audit_summary(
SELECT jsonb_agg(
jsonb_build_object(
'prefix', prefix,
'total', total
'total', total,
'recent_24h_total', recent_24h_total,
'first_sent_at', first_sent_at,
'last_sent_at', last_sent_at
)
ORDER BY total DESC, prefix ASC
)
@@ -515,7 +518,13 @@ async def _fetch_callback_reply_audit_summary(
),
'unknown'
) AS prefix,
COUNT(*) AS total
COUNT(*) AS total,
COUNT(*) FILTER (
WHERE COALESCE(sent_at, queued_at)
>= NOW() - INTERVAL '24 hours'
) AS recent_24h_total,
MIN(COALESCE(sent_at, queued_at)) AS first_sent_at,
MAX(COALESCE(sent_at, queued_at)) AS last_sent_at
FROM awooop_outbound_message
WHERE project_id = :project_id
AND channel_type = 'telegram'
@@ -693,6 +702,9 @@ def _reply_markup_gap_prefixes_from_value(value: Any) -> list[dict[str, Any]]:
prefixes.append({
"prefix": prefix[:80],
"total": _safe_int(item.get("total")),
"recent_24h_total": _safe_int(item.get("recent_24h_total")),
"first_sent_at": item.get("first_sent_at"),
"last_sent_at": item.get("last_sent_at"),
})
if len(prefixes) >= 5:
break