Files
Nexus/docs/changelog/2026-06-08-alerts-commands-schedules-contract-fix.md
T
Nexus Agent 0f6f91e61a fix(api): align alerts/commands contracts and ship full-site test suite.
Restore alert history filters and stats fields, paginate command/session logs for the SPA, show script labels on schedules, and land integration/E2E coverage with rebuilt web assets.
2026-06-09 02:13:13 +08:00

1.7 KiB
Raw Blame History

2026-06-08 告警中心 / 命令日志 / 调度契约修复

摘要

修复告警中心统计与筛选、命令日志表格恒空、调度列表脚本列空白等前后端 API 契约不一致问题。

动机

全站 E2E 仅验证页面可打开,未覆盖真实查询参数与响应结构;生产上三页表现为数据为空、统计恒 0、筛选无效。

变更

告警中心(server/api/settings.py

  • GET /api/alert-history/:支持前端 page/per_pagetype(→ alert_type)、statusactive/recoveredis_recovery);响应补充 page/per_page/pages
  • GET /api/alert-history/stats:补充 today/active/recovered/top_serveractive 取自 Redis alerts:* 集合基数;today 按当日日期匹配 daily;日统计 SQL 改为 SQLAlchemy 可移植查询(兼容测试 SQLite)。

命令日志(server/api/assets.py

  • GET /api/assets/command-logs/ssh-sessions:由裸数组改为 { items, total, page, per_page, pages },与 fetchPagePerPage 一致。

调度(frontend/src/pages/SchedulesPage.vue

  • 列表「源文件 / 脚本」列:脚本类型显示脚本库名称或命令摘要,不再空白。

涉及文件

  • server/api/settings.py
  • server/api/assets.py
  • frontend/src/pages/SchedulesPage.vue
  • tests/integration/test_alerts_audit.py
  • tests/integration/test_retries_commands.py

迁移 / 重启

  • 无需 DB 迁移;需重启 API 并重新构建前端后部署。

验证

.venv/bin/pytest tests/integration/test_alerts_audit.py tests/integration/test_retries_commands.py -q
bash scripts/local_verify.sh
cd frontend && npm run build