Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix bug with `has_pageviews?`

Uku Taht761072d2858d
diff --git a/lib/plausible/stats/clickhouse.ex b/lib/plausible/stats/clickhouse.ex
index 2080cabef6..80e7b46699 100644
--- a/lib/plausible/stats/clickhouse.ex
+++ b/lib/plausible/stats/clickhouse.ex
@@ -407,6 +407,7 @@ defmodule Plausible.Stats.Clickhouse do
res["visitors"]
end
+ def has_pageviews?([]), do: false
def has_pageviews?(domains) when is_list(domains) do
res = Clickhouse.all(
from e in "events",
diff --git a/test/plausible/auth/auth_test.exs b/test/plausible/auth/auth_test.exs
index 3b792faced..365bf5fb7f 100644
--- a/test/plausible/auth/auth_test.exs
+++ b/test/plausible/auth/auth_test.exs
@@ -3,6 +3,12 @@ defmodule Plausible.AuthTest do
alias Plausible.Auth
describe "user_completed_setup?" do
+ test "is false if user does not have any sites" do
+ user = insert(:user)
+
+ refute Auth.user_completed_setup?(user)
+ end
+
test "is false if user does not have any events" do
user = insert(:user)
insert(:site, members: [user])