fix(awooop): keep callback audit summary stable
This commit is contained in:
@@ -401,7 +401,7 @@ async def list_callback_replies(
|
||||
total = count_result.scalar_one()
|
||||
rows_result = await db.execute(list_sql, params)
|
||||
rows = list(rows_result.mappings().all())
|
||||
summary = await _fetch_callback_reply_audit_summary(
|
||||
audit_summary = await _fetch_callback_reply_audit_summary(
|
||||
db,
|
||||
project_id=project_id or "awoooi",
|
||||
)
|
||||
@@ -446,22 +446,22 @@ async def list_callback_replies(
|
||||
item["awooop_status_chain"] = chain
|
||||
|
||||
summary_cache_key = (item_project_id, incident_id)
|
||||
summary = km_completion_summary_cache.get(summary_cache_key)
|
||||
if summary is None:
|
||||
summary = await _fetch_km_stale_completion_summary_for_incident(
|
||||
km_summary = km_completion_summary_cache.get(summary_cache_key)
|
||||
if km_summary is None:
|
||||
km_summary = await _fetch_km_stale_completion_summary_for_incident(
|
||||
project_id=item_project_id,
|
||||
incident_id=incident_id,
|
||||
queue_cache=km_completion_queue_cache,
|
||||
)
|
||||
km_completion_summary_cache[summary_cache_key] = summary
|
||||
item["km_stale_completion_summary"] = summary
|
||||
km_completion_summary_cache[summary_cache_key] = km_summary
|
||||
item["km_stale_completion_summary"] = km_summary
|
||||
|
||||
return {
|
||||
"items": items,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"per_page": per_page,
|
||||
"summary": summary,
|
||||
"summary": audit_summary,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import inspect
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from types import SimpleNamespace
|
||||
@@ -706,6 +707,15 @@ def test_list_callback_replies_response_preserves_callback_evidence() -> None:
|
||||
assert dumped["summary"]["snapshot_status"] == "not_captured"
|
||||
|
||||
|
||||
def test_list_callback_replies_keeps_audit_summary_separate_from_km_summary() -> None:
|
||||
source = inspect.getsource(platform_operator_service.list_callback_replies)
|
||||
|
||||
assert "audit_summary = await _fetch_callback_reply_audit_summary" in source
|
||||
assert '"summary": audit_summary' in source
|
||||
assert "km_summary = km_completion_summary_cache.get" in source
|
||||
assert 'item["km_stale_completion_summary"] = km_summary' in source
|
||||
|
||||
|
||||
def test_callback_reply_audit_summary_marks_missing_snapshots() -> None:
|
||||
summary = _callback_reply_audit_summary_from_row(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user