Skip to content

Commit

Permalink
fix test and native scroll depth sum select
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertJoonas committed Dec 19, 2024
1 parent 91ff5a7 commit 9470502
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/plausible/stats/sql/special_metrics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ defmodule Plausible.Stats.SQL.SpecialMetrics do
subquery(max_per_visitor_q)
|> select([p], %{
scroll_depth_sum:
fragment("if(isNull(sum(?)), NULL, sum(?))", p.max_scroll_depth, p.max_scroll_depth),
fragment("if(count(?) = 0, NULL, sum(?))", p.user_id, p.max_scroll_depth),
total_visitors: fragment("count(?)", p.user_id)
})
|> select_merge(^dim_select)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest do
]
end

test ":is filter on page returns only visitors, visits and pageviews", %{
test ":is filter on page returns only visitors, visits, pageviews and scroll_depth", %{
conn: conn,
site: site
} do
Expand Down Expand Up @@ -638,7 +638,8 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest do
assert res["top_stats"] == [
%{"name" => "Unique visitors", "value" => 2, "graph_metric" => "visitors"},
%{"name" => "Total visits", "value" => 4, "graph_metric" => "visits"},
%{"name" => "Total pageviews", "value" => 36, "graph_metric" => "pageviews"}
%{"name" => "Total pageviews", "value" => 36, "graph_metric" => "pageviews"},
%{"name" => "Scroll depth", "value" => nil, "graph_metric" => "scroll_depth"}
]
end
end
Expand Down

0 comments on commit 9470502

Please sign in to comment.