From 6826f37bbdc666b055102e2dd84744f4e05a8dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zhero=20=26=20=E5=8A=A9=E7=90=86?= Date: Thu, 3 Dec 2026 22:33:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(qa-dashboard):=20=E8=B6=8B=E5=8A=BF?= =?UTF-8?q?=E6=8C=89=E5=8C=97=E4=BA=AC=E6=97=A5=E6=9C=9F=E5=88=87=E5=8C=BA?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E5=91=A8/=E6=9C=88=E7=9C=8B=E6=9D=BF?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E8=A2=AB=E5=88=A4=E5=93=8D=E5=BA=94=E6=97=A0?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/qaopsmirror/dashboard_period_integration_test.go | 4 ++++ internal/qaopsmirror/dashboard_store.go | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/qaopsmirror/dashboard_period_integration_test.go b/internal/qaopsmirror/dashboard_period_integration_test.go index f1a81c9..747b9a1 100644 --- a/internal/qaopsmirror/dashboard_period_integration_test.go +++ b/internal/qaopsmirror/dashboard_period_integration_test.go @@ -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, diff --git a/internal/qaopsmirror/dashboard_store.go b/internal/qaopsmirror/dashboard_store.go index 2b2d622..263b335 100644 --- a/internal/qaopsmirror/dashboard_store.go +++ b/internal/qaopsmirror/dashboard_store.go @@ -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