fix: 修复Agent指标时区查询

- 统一Agent报告存储与查询的UTC时间边界
- 修复监控大屏、历史图表及离线判断取不到最新数据
- 增加UTC与UTC+8场景回归测试
This commit is contained in:
Logan.Li committed 2026-07-25 16:17:47 +08:00
1 parent d9106dde6e
commit 7bc416d22a
6 files changed
+83 -9

No files matched your search

+2 -1
View File
@@ -144,7 +144,8 @@ func (s *Service) MetricSummary(ctx context.Context, target, metric, timeRange s
}
since := sinceByRange(timeRange, time.Hour)
var reports []model.AgentReport
if err := s.db.WithContext(ctx).Where("hostname = ? AND report_time >= ?", hostname, since).
// Agent 指标时间统一为 UTC,确保 SQLite 按时间文本比较能命中数据。 // Logan.Li
if err := s.db.WithContext(ctx).Where("hostname = ? AND report_time >= ?", hostname, since.UTC()).
Order("report_time ASC").Limit(limit).Find(&reports).Error; err != nil {
return nil, err
}