664efb9ed5
Sample fleet averages every heartbeat flush into fleet_metric_samples; expose GET /api/servers/fleet-metrics and Dashboard sparkline card (B-02). Co-authored-by: Cursor <cursoragent@cursor.com>
901 B
901 B
B-02 Dashboard 24h 趋势 — 实施计划
文件清单
| 层 | 文件 |
|---|---|
| Domain | server/domain/models/__init__.py — FleetMetricSample |
| Infra | server/infrastructure/database/fleet_metric_repo.py |
| Background | server/background/heartbeat_flush.py — 采样 + purge |
| API | server/api/servers.py — GET /fleet-metrics |
| 迁移 | server/infrastructure/database/migrations.py |
| 前端 | frontend/src/components/dashboard/DashboardTrendChart.vue |
| 前端 | frontend/src/pages/DashboardPage.vue |
| 测试 | tests/test_fleet_metrics.py |
步骤
- 建表迁移 + ORM
- repo:insert_sample / list_since / purge_older_than
- heartbeat_flush 末尾聚合 Redis 并 insert
- API + Pydantic 响应
- SVG 图表组件 + Dashboard 挂载
- pytest + changelog + audit
回滚
- 删除 API 与前端卡片即可;表可保留无影响。