chore(api): 新增 debug endpoint 測試 incident resolve
臨時測試端點,用於驗證 resolve_incident_after_approval 邏輯 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -338,3 +338,54 @@ async def generate_proposal(incident_id: str) -> ProposalGenerateResponse:
|
||||
proposal=ApprovalRequestResponse.from_approval(approval),
|
||||
incident_status=incident_status,
|
||||
)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# DEBUG: 測試 Incident 狀態更新
|
||||
# =============================================================================
|
||||
|
||||
@router.post(
|
||||
"/{incident_id}/resolve",
|
||||
summary="[DEBUG] 直接將 Incident 標記為 RESOLVED",
|
||||
description="測試用端點,直接更新 Incident 狀態",
|
||||
)
|
||||
async def debug_resolve_incident(incident_id: str) -> dict[str, Any]:
|
||||
"""
|
||||
DEBUG: 直接更新 Incident 狀態為 RESOLVED
|
||||
用於測試 resolve_incident_after_approval 邏輯
|
||||
"""
|
||||
service = get_proposal_service()
|
||||
|
||||
# 先取得當前狀態
|
||||
redis_client = get_redis()
|
||||
before_status = None
|
||||
try:
|
||||
data = await redis_client.get(f"incident:{incident_id}")
|
||||
if data:
|
||||
incident = Incident.model_validate_json(data)
|
||||
before_status = incident.status.value
|
||||
except Exception as e:
|
||||
logger.warning("debug_resolve_get_failed", error=str(e))
|
||||
|
||||
# 呼叫 resolve
|
||||
result = await service.resolve_incident_after_approval(
|
||||
incident_id=incident_id,
|
||||
approval_id="debug-test",
|
||||
)
|
||||
|
||||
# 取得更新後狀態
|
||||
after_status = None
|
||||
try:
|
||||
data = await redis_client.get(f"incident:{incident_id}")
|
||||
if data:
|
||||
incident = Incident.model_validate_json(data)
|
||||
after_status = incident.status.value
|
||||
except Exception as e:
|
||||
logger.warning("debug_resolve_get_after_failed", error=str(e))
|
||||
|
||||
return {
|
||||
"success": result,
|
||||
"incident_id": incident_id,
|
||||
"before_status": before_status,
|
||||
"after_status": after_status,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user