From 4c40ea96e3849d38fcf4bcfa5d8e277af0e8b608 Mon Sep 17 00:00:00 2001 From: furyhawk Date: Wed, 22 Apr 2026 22:44:50 +0800 Subject: [PATCH] fix: adjust batch window size in fetchMetric for optimized data fetching based on range Co-authored-by: Copilot --- frontend/src/components/dashboard/furyDashboardApi.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/dashboard/furyDashboardApi.ts b/frontend/src/components/dashboard/furyDashboardApi.ts index 1a7eb3e..6dad78f 100644 --- a/frontend/src/components/dashboard/furyDashboardApi.ts +++ b/frontend/src/components/dashboard/furyDashboardApi.ts @@ -156,8 +156,10 @@ const fetchMetric = async ( const endMs = Date.now() const startMs = Math.max(0, endMs - summarySinceMs) - // size of each batch window (7 days) - const batchMs = DAY_IN_MS * 7 + // size of each batch window. For short ranges (<= 7 days) fetch daily + // batches so a 1-week range will request seven 1-day windows. For longer + // ranges use 7-day windows to reduce iteration count. + const batchMs = summarySinceMs <= DAY_IN_MS * 7 ? DAY_IN_MS : DAY_IN_MS * 7 const maxIterations = 200 let currentEndMs = endMs