Type Alias: ActivityGrain
ActivityGrain = typeof
ActivityGrain[keyof typeofActivityGrain]
Defined in: packages/sdk/src/types/generated/activity_feed.ts:371
How coarsely to aggregate — or not to aggregate at all.
MONTH, WEEK, DAY and HOUR are read from
activity_rollup_hourly: hour is the materialized grain, and every
coarser one is a SUM over it at read time. There is deliberately no
second rollup table, so no two grains can disagree — which is also why
adding WEEK needed no migration and no new materialization. It is the
same arithmetic over the same buckets, with a different truncation.
Weeks start on Sunday, because this codebase already decided that:
every calendar surface passes weekStartsOn: 0 and
src/lib/date-utils.ts::startOfWeekInTimezone defaults to it. A second
week convention in the same product is worse than either convention, and
PostgreSQL's date_trunc('week', …) — which is ISO/Monday — is therefore
shifted rather than used directly (lib/db/activities/feed.py).
EVENT is the leaf: it reads activity_events directly, by which
point the query is always scoped to a workspace (or the account lane), a
time range and usually a type — the shape of the log's leading index.
Anything finer than an hour is deliberately absent from this enum rather
than unimplemented: hourly is the materialization ceiling, and sub-hourly
resolution is a GROUP BY over the log at query time when a consumer
exists for it.