Helpers for time-bucket analysis.
label/2computes the bucket label for the in-memory aggregation path used by the engine (works on any data layer, including ETS/Simple).expr/2is a reference helper that builds a Postgresdate_trunc-style fragment. It is provided for a future SQL pushdown optimization; the engine currently aggregates time buckets in memory so the behaviour is identical across data layers.
Summary
Functions
Build a date_trunc-style expression for the given time field and bucket.
Compute a human-readable bucket label for an in-memory fallback (ETS/Simple).
Functions
@spec expr(atom(), AshDyan.time_bucket()) :: Macro.t()
Build a date_trunc-style expression for the given time field and bucket.
Reference helper for a future SQL pushdown optimization.
@spec label(DateTime.t() | NaiveDateTime.t() | Date.t() | nil, AshDyan.time_bucket()) :: String.t() | nil
Compute a human-readable bucket label for an in-memory fallback (ETS/Simple).
For :week we use the Monday of the ISO week. For :quarter we use the
quarter start month.