View Source Plausible.Sites (Plausible v0.0.1)
Sites context functions.
Summary
Functions
Returns the date of the first recorded stat in the timezone configured by the user. This function does 2 transformations: UTC %NaiveDateTime{} -> Local %DateTime{} -> Local %Date
Returns the date of the first event of the given site, or nil
if the site
does not have stats yet.
Types
@type list_opt() :: {:filter_by_domain, String.t()}
Functions
@spec clear_stats_start_date!(Plausible.Site.t()) :: Plausible.Site.t()
get_for_user!(user_id, domain, roles \\ [:owner, :admin, :viewer])
View Source@spec list(Plausible.Auth.User.t(), map(), [list_opt()]) :: Scrivener.Page.t()
@spec list_with_invitations(Plausible.Auth.User.t(), map(), [list_opt()]) :: Scrivener.Page.t()
@spec local_start_date(Plausible.Site.t()) :: Date.t() | nil
Returns the date of the first recorded stat in the timezone configured by the user. This function does 2 transformations: UTC %NaiveDateTime{} -> Local %DateTime{} -> Local %Date
Examples
iex> Plausible.Site.local_start_date(%Plausible.Site{stats_start_date: nil}) nil
iex> utc_start = ~N[2022-09-28 00:00:00] iex> tz = "Europe/Helsinki" iex> site = %Plausible.Site{stats_start_date: utc_start, timezone: tz} iex> Plausible.Site.local_start_date(site) ~D[2022-09-28]
iex> utc_start = ~N[2022-09-28 00:00:00] iex> tz = "America/Los_Angeles" iex> site = %Plausible.Site{stats_start_date: utc_start, timezone: tz} iex> Plausible.Site.local_start_date(site) ~D[2022-09-27]
@spec set_option(Plausible.Auth.User.t(), Plausible.Site.t(), atom(), any()) :: Plausible.Site.UserPreference.t()
@spec stats_start_date(Plausible.Site.t()) :: Date.t() | nil
Returns the date of the first event of the given site, or nil
if the site
does not have stats yet.
If this is the first time the function is called for the site, it queries imported stats and Clickhouse, choosing the earliest start date and saves it in the sites table.
@spec toggle_pin(Plausible.Auth.User.t(), Plausible.Site.t()) :: {:ok, Plausible.Site.UserPreference.t()} | {:error, :too_many_pins}