Fix realtime conversion report (#260)

This commit is contained in:
Uku Taht 2020-08-03 15:56:14 +03:00 committed by GitHub
parent b29afdeb92
commit e2e901df98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View File

@ -649,7 +649,7 @@ defmodule Plausible.Stats.Clickhouse do
q =
from(s in "sessions",
where: s.domain == ^site.domain,
where: s.start >= ^first_datetime and s.start < ^last_datetime
where: s.timestamp >= ^first_datetime and s.start < ^last_datetime
)
q =
@ -708,17 +708,15 @@ defmodule Plausible.Stats.Clickhouse do
end
end
defp utc_boundaries(%Query{period: "30m"}, timezone) do
last_datetime =
NaiveDateTime.utc_now() |> Timex.to_datetime(timezone) |> Timex.Timezone.convert("UTC")
defp utc_boundaries(%Query{period: "30m"}, _timezone) do
last_datetime = NaiveDateTime.utc_now()
first_datetime = last_datetime |> Timex.shift(minutes: -30)
{first_datetime, last_datetime}
end
defp utc_boundaries(%Query{period: "realtime"}, timezone) do
last_datetime =
NaiveDateTime.utc_now() |> Timex.to_datetime(timezone) |> Timex.Timezone.convert("UTC")
defp utc_boundaries(%Query{period: "realtime"}, _timezone) do
last_datetime = NaiveDateTime.utc_now()
first_datetime = last_datetime |> Timex.shift(minutes: -5)
{first_datetime, last_datetime}

View File

@ -218,7 +218,8 @@ defmodule Plausible.Test.ClickhouseSetup do
session_id: @conversion_1_session_id,
is_bounce: true,
duration: 100,
start: ~N[2019-01-01 02:00:00]
start: ~N[2019-01-01 02:00:00],
timestamp: ~N[2019-01-01 02:00:00]
},
%{
domain: "test-site.com",
@ -229,7 +230,8 @@ defmodule Plausible.Test.ClickhouseSetup do
session_id: @conversion_2_session_id,
is_bounce: false,
duration: 0,
start: ~N[2019-01-01 02:00:00]
start: ~N[2019-01-01 02:00:00],
timestamp: ~N[2019-01-01 02:00:00]
},
%{
domain: "test-site.com",
@ -239,7 +241,8 @@ defmodule Plausible.Test.ClickhouseSetup do
referrer: "",
is_bounce: false,
duration: 100,
start: ~N[2019-01-01 03:00:00]
start: ~N[2019-01-01 03:00:00],
timestamp: ~N[2019-01-01 03:00:00]
},
%{
domain: "test-site.com",