Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix custom date format

Uku Taht945320902363
diff --git a/lib/plausible/stats/query.ex b/lib/plausible/stats/query.ex
index 701037472c..2017db2ead 100644
--- a/lib/plausible/stats/query.ex
+++ b/lib/plausible/stats/query.ex
@@ -146,6 +146,16 @@ defmodule Plausible.Stats.Query do
}
end
+ def from(tz, %{"period" => "custom", "from" => from, "to" => to} = params) do
+ new_params =
+ params
+ |> Map.delete("from")
+ |> Map.delete("to")
+ |> Map.put("date", Enum.join([from, to], ","))
+
+ from(tz, new_params)
+ end
+
def from(_tz, %{"period" => "custom", "date" => date} = params) do
[from, to] = String.split(date, ",")
from_date = Date.from_iso8601!(from)
@@ -159,10 +169,6 @@ defmodule Plausible.Stats.Query do
}
end
- def from(tz, %{"period" => "custom", "from" => from, "to" => to} = params) do
- from(tz, Map.merge(params, %{"period" => "custom", "date" => Enum.join([from, to], ",")}))
- end
-
def from(tz, _) do
__MODULE__.from(tz, %{"period" => "30d"})
end