diff --git a/apps/web/src/api/warehouse/services.test.ts b/apps/web/src/api/warehouse/services.test.ts index b93bc6431..8006d4594 100644 --- a/apps/web/src/api/warehouse/services.test.ts +++ b/apps/web/src/api/warehouse/services.test.ts @@ -289,4 +289,16 @@ describe("getServiceOverview throughput resolution", () => { ]) }), ) + + // Live clock: the TestClock sits at epoch 0, where the fallback window has no positive start. + it.live("divides by the default 24h window it queried when no range is passed", () => + Effect.gen(function* () { + setActiveOrgId("overview-default-window") + const { data } = yield* getServiceOverview({ data: {} }) + + // 100 spans over the 24h fallback window, not over a 1h fallback duration. + const expected = 100 / (24 * 3600) + assert.ok(Math.abs(data[0].throughput - expected) < 1e-9, `throughput=${data[0].throughput}`) + }), + ) }) diff --git a/apps/web/src/api/warehouse/services.ts b/apps/web/src/api/warehouse/services.ts index 5d96a41bc..8cc8a9c06 100644 --- a/apps/web/src/api/warehouse/services.ts +++ b/apps/web/src/api/warehouse/services.ts @@ -98,7 +98,9 @@ const getServiceOverviewEffect = Effect.fn("QueryEngine.getServiceOverview")(fun ) return { - data: coerceServiceOverviewRows(result.data, windowDurationSeconds(input.startTime, input.endTime)), + // The window the query actually ran on: the raw inputs fall back to 3600s, + // which would turn a 24h default window into a 24x-inflated rate. + data: coerceServiceOverviewRows(result.data, windowDurationSeconds(startTime, endTime)), } })