fix(qa-dashboard): 趋势按北京日期切区间,周/月看板不再被判响应无效
build / build (push) Successful in 1m57s

This commit is contained in:
Zhero & 助理
2026-12-03 22:33:52 +08:00
committed by 姚章浩
parent 86343d286e
commit 6826f37bbd
2 changed files with 9 additions and 1 deletions
@@ -40,6 +40,10 @@ func TestMonthlyGranularityCutsEveryPanelFromTheSelectedRange(t *testing.T) {
}
start, _ := time.Parse(time.RFC3339, "2026-11-01T00:00:00+08:00")
end, _ := time.Parse(time.RFC3339, "2026-12-01T00:00:00+08:00")
// The handler builds the window through dobotaiops.NewWindow, which
// normalises both ends to UTC. Feed the store the same shape here, otherwise
// this test keeps a +08 location the production path never has.
start, end = start.UTC(), end.UTC()
got, err := s.ReadMasterDashboard(ctx, dobotaiops.RecordQuery{
Window: dobotaiops.Window{TenantKey: s.tenant, Start: start, End: end},
Granularity: dashboardGranularityMonth,
+5 -1
View File
@@ -226,7 +226,11 @@ func (s *Store) readDashboard(ctx context.Context, q dobotaiops.RecordQuery, mas
products, types, daily := map[string]int{}, map[string]int{}, map[string]int{}
dailyFrom := out.WeekStart
if q.Granularity != "" {
dailyFrom = q.Window.Start
// Window.Start is UTC (NewWindow normalises it); the trend keys and the
// per-record buckets are Beijing dates, so cut the range in Beijing time
// or the first/last day drifts by one and the last day's records fall
// outside the pre-filled keys (the board then looks inconsistent).
dailyFrom = q.Window.Start.In(dashboardLocation)
}
for day := dailyFrom; day.Before(q.Window.End); day = day.AddDate(0, 0, 1) {
daily[day.Format("2006-01-02")] = 0