@ -29,8 +29,10 @@ defmodule Plausible.Funnels do
def list(%Plausible.Site{id: site_id}) do
Repo.all(
from(f in Funnel,
inner_join: steps in assoc(f, :steps),
where: f.site_id == ^site_id,
select: %{name: f.name, id: f.id},
select: %{name: f.name, id: f.id, steps_count: count(steps)},
group_by: f.id,
order_by: [desc: :id]
)
@ -11,6 +11,10 @@ defmodule PlausibleWeb.Live.FunnelSettings.List do
<div class="border-b border-gray-300 dark:border-gray-500 py-3 flex justify-between">
<span class="text-sm font-medium text-gray-900 dark:text-gray-100">
<%= funnel.name %>
<br />
<span class="text-sm text-gray-400 font-normal">
<%= funnel.steps_count %>-step funnel
</span>
<%= button(to: "", method: :delete, class: "text-sm text-red-600", data: [confirm: "Are you sure you want to remove funnel '#{funnel.name}'? This will just affect the UI, all of your analytics data will stay intact."]) do %>
<svg
@ -85,11 +85,13 @@ defmodule Plausible.FunnelsTest do
site: site,
steps: [g1, g2, g3 | _]
} do
Funnels.create(site, "Funnel 1", [g3, g1, g2])
Funnels.create(site, "Funnel 1", [g3, g1])
Funnels.create(site, "Funnel 2", [g2, g1, g3])
funnels_list = Funnels.list(site)
assert [%{name: "Funnel 2"}, %{name: "Funnel 1"}] = funnels_list
assert [%{name: "Funnel 2", steps_count: 3}, %{name: "Funnel 1", steps_count: 2}] =
funnels_list
end
test "funnels can be evaluated per site within a time range", %{