|
|
|
@ -23,7 +23,7 @@ defmodule Plausible.Stats.Imported do
|
|
|
|
select: %{}
|
|
|
|
select: %{}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|> select_imported_metrics(metrics)
|
|
|
|
|> select_imported_metrics(metrics)
|
|
|
|
|> apply_interval(query, site.timezone)
|
|
|
|
|> apply_interval(query, site)
|
|
|
|
|
|
|
|
|
|
|
|
from(s in Ecto.Query.subquery(native_q),
|
|
|
|
from(s in Ecto.Query.subquery(native_q),
|
|
|
|
full_join: i in subquery(imported_q),
|
|
|
|
full_join: i in subquery(imported_q),
|
|
|
|
@ -33,21 +33,21 @@ defmodule Plausible.Stats.Imported do
|
|
|
|
|> select_joined_metrics(metrics)
|
|
|
|
|> select_joined_metrics(metrics)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
defp apply_interval(imported_q, %Plausible.Stats.Query{interval: "month"}, _timezone) do
|
|
|
|
defp apply_interval(imported_q, %Plausible.Stats.Query{interval: "month"}, _site) do
|
|
|
|
imported_q
|
|
|
|
imported_q
|
|
|
|
|> group_by([i], fragment("toStartOfMonth(?)", i.date))
|
|
|
|
|> group_by([i], fragment("toStartOfMonth(?)", i.date))
|
|
|
|
|> select_merge([i], %{date: fragment("toStartOfMonth(?)", i.date)})
|
|
|
|
|> select_merge([i], %{date: fragment("toStartOfMonth(?)", i.date)})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
defp apply_interval(imported_q, %Plausible.Stats.Query{interval: "week"} = query, timezone) do
|
|
|
|
defp apply_interval(imported_q, %Plausible.Stats.Query{interval: "week"} = query, site) do
|
|
|
|
{first_datetime, _} = utc_boundaries(query, timezone)
|
|
|
|
{first_datetime, _} = utc_boundaries(query, site)
|
|
|
|
|
|
|
|
|
|
|
|
imported_q
|
|
|
|
imported_q
|
|
|
|
|> group_by([i], weekstart_not_before(i.date, ^first_datetime))
|
|
|
|
|> group_by([i], weekstart_not_before(i.date, ^first_datetime))
|
|
|
|
|> select_merge([i], %{date: weekstart_not_before(i.date, ^first_datetime)})
|
|
|
|
|> select_merge([i], %{date: weekstart_not_before(i.date, ^first_datetime)})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
defp apply_interval(imported_q, _query, _timezone) do
|
|
|
|
defp apply_interval(imported_q, _query, _site) do
|
|
|
|
imported_q
|
|
|
|
imported_q
|
|
|
|
|> group_by([i], i.date)
|
|
|
|
|> group_by([i], i.date)
|
|
|
|
|> select_merge([i], %{date: i.date})
|
|
|
|
|> select_merge([i], %{date: i.date})
|
|
|
|
|