Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Drop `local_start_date/1` (#4088)
ruslandoga84ed7988a8ad
diff --git a/lib/plausible/sites.ex b/lib/plausible/sites.exindex 12d4235adf..eb792946ff 100644--- a/lib/plausible/sites.ex+++ b/lib/plausible/sites.ex@@ -196,35 +196,6 @@ defmodule Plausible.Sites do|> Plausible.Repo.update!()end- @doc """- 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 local_start_date(Site.t()) :: Date.t() | nil- def local_start_date(site) do- if stats_start_date = stats_start_date(site) do- Plausible.Timezones.to_date_in_timezone(stats_start_date, site.timezone)- end- end-@spec stats_start_date(Site.t()) :: Date.t() | nil@doc """Returns the date of the first event of the given site, or `nil` if the sitediff --git a/lib/plausible/stats/query.ex b/lib/plausible/stats/query.exindex bf4adaeace..00bf937ed8 100644--- a/lib/plausible/stats/query.ex+++ b/lib/plausible/stats/query.ex@@ -150,7 +150,7 @@ defmodule Plausible.Stats.Query dodefp put_period(query, site, %{"period" => "all"}) donow = today(site.timezone)- start_date = Plausible.Sites.local_start_date(site) || now+ start_date = Plausible.Sites.stats_start_date(site) || nowstruct!(query,period: "all",diff --git a/test/plausible/stats/query_test.exs b/test/plausible/stats/query_test.exsindex c56e0f978a..3e38c748e3 100644--- a/test/plausible/stats/query_test.exs+++ b/test/plausible/stats/query_test.exs@@ -105,7 +105,7 @@ defmodule Plausible.Stats.QueryTest dosite = Map.put(site, :timezone, "America/Cancun")q = Query.from(site, %{"period" => "all"})- assert q.date_range.first == ~D[2019-12-31]+ assert q.date_range.first == ~D[2020-01-01]assert q.date_range.last == Timex.today("America/Cancun")end