0f6f91e61a
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.
1.7 KiB
1.7 KiB
2026-06-08 告警中心 / 命令日志 / 调度契约修复
摘要
修复告警中心统计与筛选、命令日志表格恒空、调度列表脚本列空白等前后端 API 契约不一致问题。
动机
全站 E2E 仅验证页面可打开,未覆盖真实查询参数与响应结构;生产上三页表现为数据为空、统计恒 0、筛选无效。
变更
告警中心(server/api/settings.py)
GET /api/alert-history/:支持前端page/per_page、type(→alert_type)、status(active/recovered→is_recovery);响应补充page/per_page/pages。GET /api/alert-history/stats:补充today/active/recovered/top_server;active取自 Redisalerts:*集合基数;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.pyserver/api/assets.pyfrontend/src/pages/SchedulesPage.vuetests/integration/test_alerts_audit.pytests/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