Skip to content

Commit

Permalink
rename total_visitors to pageleave_visitors
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertJoonas committed Jan 6, 2025
1 parent 7b5eeeb commit 3203218
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/plausible/stats/imported/sql/expression.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ defmodule Plausible.Stats.Imported.SQL.Expression do
defp select_metric(:scroll_depth, "imported_pages") do
wrap_alias([i], %{
scroll_depth_sum: sum(i.scroll_depth),
total_visitors: sum(i.pageleave_visitors)
pageleave_visitors: sum(i.pageleave_visitors)
})
end

Expand Down Expand Up @@ -366,7 +366,7 @@ defmodule Plausible.Stats.Imported.SQL.Expression do
q
|> select_merge_as([s, i], %{
__internal_scroll_depth_sum: i.scroll_depth_sum,
__internal_total_visitors: i.total_visitors
__internal_pageleave_visitors: i.pageleave_visitors
})
|> select_joined_metrics(rest)
end
Expand Down
14 changes: 7 additions & 7 deletions lib/plausible/stats/sql/special_metrics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ defmodule Plausible.Stats.SQL.SpecialMetrics do
|> select([p], %{
scroll_depth_sum:
fragment("if(count(?) = 0, NULL, sum(?))", p.user_id, p.max_scroll_depth),
total_visitors: fragment("count(?)", p.user_id)
pageleave_visitors: fragment("count(?)", p.user_id)
})
|> select_merge(^dim_select)
|> group_by(^dim_group_by)
Expand Down Expand Up @@ -195,16 +195,16 @@ defmodule Plausible.Stats.SQL.SpecialMetrics do
s.scroll_depth_sum,
selected_as(:__internal_scroll_depth_sum),
s.scroll_depth_sum,
selected_as(:__internal_total_visitors),
s.total_visitors,
selected_as(:__internal_pageleave_visitors),
s.pageleave_visitors,
# Case 2: Only imported scroll depth sum is present
selected_as(:__internal_scroll_depth_sum),
selected_as(:__internal_scroll_depth_sum),
selected_as(:__internal_total_visitors),
selected_as(:__internal_pageleave_visitors),
# Case 3: Only native scroll depth sum is present
s.scroll_depth_sum,
s.scroll_depth_sum,
s.total_visitors
s.pageleave_visitors
)
})
else
Expand All @@ -213,9 +213,9 @@ defmodule Plausible.Stats.SQL.SpecialMetrics do
scroll_depth:
fragment(
"if(any(?) > 0, toUInt8(round(any(?) / any(?))), NULL)",
s.total_visitors,
s.pageleave_visitors,
s.scroll_depth_sum,
s.total_visitors
s.pageleave_visitors
)
})
end
Expand Down

0 comments on commit 3203218

Please sign in to comment.