feat(databi): query china stat timezone

This commit is contained in:
zhx 2026-06-25 14:31:16 +08:00
parent 88ef541b95
commit 9405e2b7d6
3 changed files with 29 additions and 5 deletions

View File

@ -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 || {});

View File

@ -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(<DatabiApp />);
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();
});

View File

@ -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);
}