fix(approval): map rejected incidents to escalated
Some checks failed
CD Pipeline / tests (push) Successful in 1m38s
Code Review / ai-code-review (push) Successful in 33s
CD Pipeline / build-and-deploy (push) Successful in 4m42s
CD Pipeline / post-deploy-checks (push) Has been cancelled

This commit is contained in:
Your Name
2026-05-26 00:24:51 +08:00
parent b019a982d8
commit 480292b04d
2 changed files with 9 additions and 6 deletions

View File

@@ -37,8 +37,8 @@ REDIS_KEY_DECISION = "decision:"
APPROVAL_TO_INCIDENT_STATUS = {
"pending": "investigating",
"approved": "resolved",
"rejected": "rejected",
"expired": "expired",
"rejected": "escalated",
"expired": "escalated",
}
# Incident 狀態 → 是否活躍

View File

@@ -35,6 +35,7 @@ from src.core.constants import (
from src.core.unit_of_work import UnitOfWork
from src.db.models import ApprovalRecord, IncidentRecord
from src.models.approval import ApprovalRequestCreate, ApprovalStatus
from src.models.incident import IncidentStatus
if TYPE_CHECKING:
from redis.asyncio import Redis
@@ -341,12 +342,14 @@ class IncidentApprovalService:
incident = result.scalar_one_or_none()
if incident:
new_incident_status = APPROVAL_TO_INCIDENT_STATUS.get(
new_status.value if hasattr(new_status, "value") else new_status,
"investigating",
new_incident_status = IncidentStatus(
APPROVAL_TO_INCIDENT_STATUS.get(
new_status.value if hasattr(new_status, "value") else new_status,
"investigating",
)
)
incident.status = new_incident_status
if new_incident_status == "resolved":
if new_incident_status == IncidentStatus.RESOLVED:
incident.resolved_at = datetime.now(UTC)
logger.info(