fix(incidents): batch decision token lookup
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 1m5s
CD Pipeline / build-and-deploy (push) Successful in 3m20s
CD Pipeline / post-deploy-checks (push) Successful in 1m19s

This commit is contained in:
Your Name
2026-05-06 21:27:35 +08:00
parent 780a742110
commit edef1aa4c7
4 changed files with 60 additions and 1 deletions

View File

@@ -30,8 +30,15 @@ class _IncidentService:
class _DecisionManager:
def __init__(self) -> None:
self.created = 0
self.single_token_lookups = 0
self.batch_token_lookups = 0
async def _find_existing_tokens_for_incidents(self, incident_ids: list[str]):
self.batch_token_lookups += 1
return {}
async def _find_existing_token(self, incident_id: str):
self.single_token_lookups += 1
return None
async def get_or_create_decision(self, *args, **kwargs):
@@ -51,3 +58,5 @@ async def test_list_incidents_does_not_trigger_ai_decision_by_default(monkeypatc
assert result.incidents[0].incident_id == "INC-20260506-PURE01"
assert result.incidents[0].decision is None
assert decision_manager.created == 0
assert decision_manager.batch_token_lookups == 1
assert decision_manager.single_token_lookups == 0