View Source Plausible.Stats.Interval (Plausible v0.0.1)
Collection of functions to work with intervals.
The interval of a query defines the granularity of the data. You can think of
it as a GROUP BY clause. Possible values are minute, hour, date,
week, and month.
Summary
Functions
Returns the suggested interval for the given Date.Range struct.
Returns the suggested interval for the given time period.
Returns whether the given interval is valid for a time period.
Types
@type opt() :: {:site, Plausible.Site.t()} | {:from, Date.t()}
@type opts() :: [opt()]
@type t() :: String.t()
Functions
@spec default_for_date_range(Date.Range.t()) :: t()
Returns the suggested interval for the given Date.Range struct.
@spec default_for_period(period()) :: t()
Returns the suggested interval for the given time period.
@spec list() :: [t()]
Returns whether the given interval is valid for a time period.
Intervals longer than periods are not supported, e.g. current month stats with a month interval, or today stats with a week interval.
There are two dynamic states:
customperiod is only applicable withmonthorweekintervals, if theopts[:from]andopts[:to]range difference exceeds 12 monthsallperiod's interval options depend on particular site'sstats_start_date- daily interval is excluded if the all-time range exceeds 12 months