fix(aiops): preserve alert identity in degraded diagnosis
This commit is contained in:
@@ -16,7 +16,7 @@ from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
import structlog
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, update
|
||||
|
||||
from src.db.base import get_db_context
|
||||
from src.db.models import ApprovalRecord
|
||||
@@ -106,8 +106,6 @@ def _record_to_request(record: ApprovalRecord) -> ApprovalRequest:
|
||||
# B4 fix 2026-04-24 ogt + Claude Sonnet 4.6: 補回 DB 欄位(人工審核路徑讀回必要)
|
||||
incident_id=getattr(record, "incident_id", None),
|
||||
matched_playbook_id=getattr(record, "matched_playbook_id", None),
|
||||
telegram_message_id=getattr(record, "telegram_message_id", None),
|
||||
telegram_chat_id=getattr(record, "telegram_chat_id", None),
|
||||
)
|
||||
|
||||
|
||||
@@ -153,7 +151,15 @@ class ApprovalDBRepository(IApprovalRepository):
|
||||
|
||||
async def get_pending(self) -> list[ApprovalRequest]:
|
||||
"""取得所有待審核的 Approval"""
|
||||
now = datetime.now(UTC)
|
||||
async with get_db_context() as db:
|
||||
await db.execute(
|
||||
update(ApprovalRecord)
|
||||
.where(ApprovalRecord.status == ApprovalStatus.PENDING)
|
||||
.where(ApprovalRecord.expires_at < now)
|
||||
.values(status=ApprovalStatus.EXPIRED, resolved_at=now)
|
||||
)
|
||||
|
||||
result = await db.execute(
|
||||
select(ApprovalRecord)
|
||||
.where(ApprovalRecord.status == ApprovalStatus.PENDING)
|
||||
|
||||
Reference in New Issue
Block a user