Do not return prop names when they are not used

This commit is contained in:
Uku Taht 2021-09-24 11:03:20 +02:00
parent f42f4da44b
commit 5be38a57fa
3 changed files with 7 additions and 6 deletions

View File

@ -23,10 +23,6 @@ defmodule Plausible.Stats.Props do
end)
end
else
query =
Plausible.Stats.Query.remove_goal(query)
|> Plausible.Stats.Query.put_filter("event:name", nil)
ClickhouseRepo.all(
from e in base_event_query(site, query),
inner_lateral_join: meta in fragment("meta as m"),

View File

@ -508,7 +508,12 @@ defmodule PlausibleWeb.Api.StatsController do
%{"visitors" => %{"value" => total_visitors}} = Stats.aggregate(site, total_q, ["visitors"])
prop_names = Stats.props(site, query)
prop_names =
if query.filters["event:goal"] do
Stats.props(site, query)
else
%{}
end
conversions =
Stats.breakdown(site, query, "event:goal", ["visitors", "events"], {100, 1})

View File

@ -37,7 +37,7 @@ defmodule PlausibleWeb.Api.StatsController.ConversionsTest do
"name" => "Signup",
"count" => 2,
"total_count" => 3,
"prop_names" => ["variant"],
"prop_names" => nil,
"conversion_rate" => 50
},
%{