fix(approval): map rejected incidents to escalated
This commit is contained in:
@@ -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 狀態 → 是否活躍
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user