fix(incidents): bind durable readback tenant context

This commit is contained in:
ogt
2026-07-11 20:10:17 +08:00
parent 476c6a6315
commit ca5ed596dc
6 changed files with 79 additions and 18 deletions

View File

@@ -168,13 +168,13 @@ class IncidentDBRepository(IIncidentRepository):
record = result.scalar_one_or_none()
return _record_to_incident(record) if record else None
async def get_active(self) -> list[Incident]:
async def get_active(self, *, project_id: str | None = None) -> list[Incident]:
"""取得所有活躍的 Incident"""
active_statuses = [
IncidentStatus.INVESTIGATING,
IncidentStatus.MITIGATING,
]
async with get_db_context() as db:
async with get_db_context(project_id) as db:
result = await db.execute(
select(IncidentRecord)
.where(IncidentRecord.status.in_(active_statuses))

View File

@@ -125,7 +125,11 @@ class IIncidentRepository(Protocol):
"""根據 ID 取得 Incident"""
...
async def get_active(self) -> list[Incident]:
async def get_active(
self,
*,
project_id: str | None = None,
) -> list[Incident]:
"""取得所有活躍的 Incident"""
...