From 2f98da8f3a4a79754966d2e1bcc4476788b47fd7 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Wed, 18 Aug 2021 12:09:40 +0300 Subject: [PATCH] Filter for pageviews when no other filter is specified in base.ex --- lib/plausible/stats/base.ex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/plausible/stats/base.ex b/lib/plausible/stats/base.ex index da502bcf1..bdffa2fb0 100644 --- a/lib/plausible/stats/base.ex +++ b/lib/plausible/stats/base.ex @@ -56,9 +56,17 @@ defmodule Plausible.Stats.Base do q = case query.filters["event:name"] do - {:is, name} -> from(e in q, where: e.name == ^name) - {:member, list} -> from(e in q, where: e.name in ^list) - nil -> q + {:is, name} -> + from(e in q, where: e.name == ^name) + + {:member, list} -> + from(e in q, where: e.name in ^list) + + # Logically, this isn't necessary and might even cause some confusion (request with no filters will still filter for event:name==pageviews). + nil -> + from(e in q, where: e.name == "pageview") + + # When removing this, however, sampling in clickhouse goes a bit weird (dashboard with 3m pageviews will start getting sampled which is weird) end q =