Revert "Include 0 length pageviews in time_on_page calculation"

This reverts commit cee79e7875.
This commit is contained in:
Uku Taht 2022-02-10 14:03:56 -06:00
parent cee79e7875
commit 5b893bde39
5 changed files with 11 additions and 11 deletions

View File

@ -232,12 +232,12 @@ defmodule Plausible.Stats.Breakdown do
time_query = "
SELECT
p,
toUInt32(avg(td)) as avgTime
round(sum(td)/count(case when p2 != p then 1 end)) as avgTime
FROM
(SELECT
p,
p2,
if(s=s2, sum(t2-t), 0) as td
sum(t2-t) as td
FROM
(SELECT
*,
@ -245,8 +245,8 @@ defmodule Plausible.Stats.Breakdown do
neighbor(p, 1) as p2,
neighbor(s, 1) as s2
FROM (#{base_query_raw}))
WHERE p IN tuple(?)
GROUP BY p,p2,s,s2)
WHERE s=s2 AND p IN tuple(?)
GROUP BY p,p2,s)
GROUP BY p"
{:ok, res} = ClickhouseRepo.query(time_query, base_query_raw_params ++ [pages])

View File

@ -1,2 +1,2 @@
name,visitors,bounce_rate,time_on_page
/some-other-page,1,,60
/some-other-page,1,,60.0

1 name visitors bounce_rate time_on_page
2 /some-other-page 1 60 60.0

View File

@ -1,3 +1,3 @@
name,visitors,bounce_rate,time_on_page
/,4,75,0
/some-other-page,1,,60
/,4,75,
/some-other-page,1,,60.0

1 name visitors bounce_rate time_on_page
2 / 4 75 0
3 /some-other-page 1 60 60.0

View File

@ -1,3 +1,3 @@
name,visitors,bounce_rate,time_on_page
/,5,80,0
/some-other-page,1,,60
/,5,80,
/some-other-page,1,,60.0

1 name visitors bounce_rate time_on_page
2 / 5 80 0
3 /some-other-page 1 60 60.0

View File

@ -52,14 +52,14 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
assert json_response(conn, 200) == [
%{
"bounce_rate" => 50.0,
"time_on_page" => 450,
"time_on_page" => 900.0,
"visitors" => 2,
"pageviews" => 2,
"name" => "/"
},
%{
"bounce_rate" => nil,
"time_on_page" => 0,
"time_on_page" => nil,
"visitors" => 1,
"pageviews" => 1,
"name" => "/some-other-page"