From 9405e2b7d66c4c8c921e5fad15cc658dc93757b6 Mon Sep 17 00:00:00 2001 From: zhx Date: Thu, 25 Jun 2026 14:31:16 +0800 Subject: [PATCH] feat(databi): query china stat timezone --- databi/src/DatabiApp.jsx | 6 ++++-- databi/src/DatabiApp.test.jsx | 18 +++++++++++++++++- databi/src/api.js | 10 ++++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/databi/src/DatabiApp.jsx b/databi/src/DatabiApp.jsx index 114d0a8..59d728c 100644 --- a/databi/src/DatabiApp.jsx +++ b/databi/src/DatabiApp.jsx @@ -110,7 +110,8 @@ export function DatabiApp() { regionId, seriesEndMs: rangeEndMs(seriesRange, timeZone), seriesStartMs: rangeStartMs(seriesRange, timeZone), - startMs + startMs, + statTz: timeZone }); const nextOverview = enrichCountryBreakdown(data || {}, scopedCountries); if (requestId === overviewRequestIdRef.current) { @@ -146,7 +147,8 @@ export function DatabiApp() { endMs: rangeEndMs(range, timeZone), gameId, regionId, - startMs: rangeStartMs(range, timeZone) + startMs: rangeStartMs(range, timeZone), + statTz: timeZone }); if (requestId === selfGameRequestIdRef.current) { setSelfGameOverview(data || {}); diff --git a/databi/src/DatabiApp.test.jsx b/databi/src/DatabiApp.test.jsx index 8766113..2e6927b 100644 --- a/databi/src/DatabiApp.test.jsx +++ b/databi/src/DatabiApp.test.jsx @@ -53,6 +53,22 @@ test("keeps current data visible during scheduled refresh", async () => { expect(document.querySelector(".metric-card.is-loading")).toBeNull(); }); +test("queries China natural day statistics when display timezone is Beijing", async () => { + fetchStatisticsOverview.mockResolvedValue({ active_users: 10, paid_users: 2, recharge_usd_minor: 100, updated_at_ms: 1 }); + + render(); + + await flushEffects(); + + expect(fetchStatisticsOverview).toHaveBeenCalledWith(expect.objectContaining({ + endMs: Date.UTC(2026, 5, 6, 15, 59, 59), + seriesEndMs: Date.UTC(2026, 5, 6, 15, 59, 59), + seriesStartMs: Date.UTC(2026, 4, 30, 16, 0, 0), + startMs: Date.UTC(2026, 5, 5, 16, 0, 0), + statTz: "Asia/Shanghai" + })); +}); + test("loads self game statistics from the big screen switch", async () => { fetchStatisticsOverview.mockResolvedValue({ active_users: 10, paid_users: 2, recharge_usd_minor: 100, updated_at_ms: 1 }); fetchSelfGameStatisticsOverview.mockResolvedValue({ @@ -69,7 +85,7 @@ test("loads self game statistics from the big screen switch", async () => { }); await flushEffects(); - expect(fetchSelfGameStatisticsOverview).toHaveBeenCalledWith(expect.objectContaining({ appCode: "lalu", gameId: "all" })); + expect(fetchSelfGameStatisticsOverview).toHaveBeenCalledWith(expect.objectContaining({ appCode: "lalu", gameId: "all", statTz: "Asia/Shanghai" })); expect(screen.getByText("Dice / Rock H5 聚合统计")).toBeTruthy(); expect(screen.getByText("创建局")).toBeTruthy(); }); diff --git a/databi/src/api.js b/databi/src/api.js index eddcb9e..ba8ea9d 100644 --- a/databi/src/api.js +++ b/databi/src/api.js @@ -16,8 +16,11 @@ export function setCurrentAppCode(value) { return appCode; } -export async function fetchStatisticsOverview({ appCode, countryId, endMs, regionId, seriesEndMs, seriesStartMs, startMs }) { +export async function fetchStatisticsOverview({ appCode, countryId, endMs, regionId, seriesEndMs, seriesStartMs, startMs, statTz }) { const query = { app_code: normalizeAppCode(appCode) || "lalu" }; + if (statTz) { + query.stat_tz = statTz; + } if (startMs) { query.start_ms = String(startMs); } @@ -40,8 +43,11 @@ export async function fetchStatisticsOverview({ appCode, countryId, endMs, regio return fetchDatabiData("/v1/statistics/overview", { appCode, query }); } -export async function fetchSelfGameStatisticsOverview({ appCode, countryId, endMs, gameId, regionId, startMs }) { +export async function fetchSelfGameStatisticsOverview({ appCode, countryId, endMs, gameId, regionId, startMs, statTz }) { const query = { app_code: normalizeAppCode(appCode) || "lalu" }; + if (statTz) { + query.stat_tz = statTz; + } if (startMs) { query.start_ms = String(startMs); }