fix(aiops): correct host alert fallback and resolved stamp
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 8m54s
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 8m54s
This commit is contained in:
@@ -1008,7 +1008,8 @@ class IncidentService:
|
||||
await repo.update_status(
|
||||
incident_id=incident_id,
|
||||
status="resolved",
|
||||
updated_at=now_taipei(),
|
||||
updated_at=incident.updated_at,
|
||||
resolved_at=incident.resolved_at,
|
||||
)
|
||||
logger.info("resolve_db_updated", incident_id=incident_id)
|
||||
except Exception as e:
|
||||
|
||||
@@ -90,6 +90,13 @@ def _smart_truncate(text: str, limit: int, suffix: str = "…[截斷]") -> str:
|
||||
return text[:limit] + suffix
|
||||
|
||||
|
||||
def _format_resolved_guard_stamp(resolved_at: datetime | None) -> str:
|
||||
"""格式化 ADR-071-D 已解決狀態守衛文案。"""
|
||||
if resolved_at is None:
|
||||
return "✅ 此事件已解決"
|
||||
return f"✅ 此事件已於 {resolved_at.strftime('%Y-%m-%d %H:%M')} 解決"
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Long Polling 配置 (Phase 5 內網修復)
|
||||
# =============================================================================
|
||||
@@ -3568,7 +3575,6 @@ class TelegramGateway:
|
||||
return None
|
||||
|
||||
if incident.status in (IncidentStatus.RESOLVED, IncidentStatus.CLOSED):
|
||||
resolved_at = incident.resolved_at.strftime("%Y-%m-%d %H:%M") if incident.resolved_at else "未知時間"
|
||||
await self._answer_callback(
|
||||
callback_query_id,
|
||||
"blocked",
|
||||
@@ -3577,7 +3583,7 @@ class TelegramGateway:
|
||||
try:
|
||||
separator = "──────────────"
|
||||
safe_original = html.escape(original_text) if original_text else ""
|
||||
stamp = f"✅ 此事件已於 {resolved_at} 解決"
|
||||
stamp = _format_resolved_guard_stamp(incident.resolved_at)
|
||||
await self._send_request("editMessageText", {
|
||||
"chat_id": self.chat_id,
|
||||
"message_id": message_id,
|
||||
|
||||
Reference in New Issue
Block a user