Skip to main content

ROLLUP_PERIODS

@forge/monorepo


@forge/monorepo / backend/src / ROLLUP_PERIODS

Variable: ROLLUP_PERIODS

const ROLLUP_PERIODS: readonly ["hour", "day", "week", "month"]

Defined in: backend/src/persistence/index.ts:451

Rollup granularities (#139).

Hour, day, week and month, and nothing finer than an hour. A minute bucket multiplies the row count sixty-fold to answer a question nobody asks.

Week and month were added by #175, because they are the periods a person's allowance is actually expressed in — "500k tokens a month" is a plan, "500k tokens a day" is not. They cannot be derived by summing days either: a month is 28 to 31 days and a week crosses month boundaries, so a caller summing day buckets has to reimplement calendar arithmetic, and two callers doing it differently is two answers to what a month cost.

A week starts Monday, in UTC, following ISO 8601 — chosen rather than defaulted, because a Sunday start would split a working week across two buckets and every weekly figure would describe half of one week and half of another.