mirror of
https://github.com/plausible/analytics.git
synced 2024-09-11 18:07:33 +03:00
Stop tagging Funnels.get/2 result
This commit is contained in:
parent
e99f61c91c
commit
242081e544
@ -69,7 +69,7 @@ defmodule Plausible.Funnels do
|
||||
end
|
||||
|
||||
@spec get(Plausible.Site.t() | pos_integer(), pos_integer()) ::
|
||||
{:ok, Funnel.t()} | {:error, String.t()}
|
||||
Funnel.t() | nil
|
||||
def get(%Plausible.Site{id: site_id}, by) do
|
||||
get(site_id, by)
|
||||
end
|
||||
@ -86,20 +86,18 @@ defmodule Plausible.Funnels do
|
||||
steps: {steps, goal: goal}
|
||||
]
|
||||
|
||||
funnel = Repo.one(q)
|
||||
|
||||
if funnel do
|
||||
{:ok, funnel}
|
||||
else
|
||||
{:error, "Funnel not found"}
|
||||
end
|
||||
Repo.one(q)
|
||||
end
|
||||
|
||||
@spec evaluate(Plausible.Stats.Query.t(), Funnel.t() | pos_integer(), Plausible.Site.t()) ::
|
||||
{:ok, Funnel.t()} | {:error, String.t()}
|
||||
{:ok, Funnel.t()} | {:error, :funnel_not_found}
|
||||
def evaluate(query, funnel_id, site) when is_integer(funnel_id) do
|
||||
with {:ok, funnel_definition} <- get(site.id, funnel_id) do
|
||||
evaluate(query, funnel_definition, site)
|
||||
case get(site.id, funnel_id) do
|
||||
%Funnel{} = funnel_definition ->
|
||||
evaluate(query, funnel_definition, site)
|
||||
|
||||
nil ->
|
||||
{:error, :funnel_not_found}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -121,10 +121,10 @@ defmodule Plausible.GoalsTest do
|
||||
|
||||
:ok = Goals.delete(g1.id, site)
|
||||
|
||||
assert {:ok, f1} = Plausible.Funnels.get(site.id, f1.id)
|
||||
assert f1 = Plausible.Funnels.get(site.id, f1.id)
|
||||
assert Enum.count(f1.steps) == 2
|
||||
|
||||
assert {:error, "Funnel not found"} = Plausible.Funnels.get(site.id, f2.id)
|
||||
refute Plausible.Funnels.get(site.id, f2.id)
|
||||
assert Repo.all(from fs in Plausible.Funnel.Step, where: fs.funnel_id == ^f2.id) == []
|
||||
|
||||
assert [^g3, ^g2] = Goals.for_site(site)
|
||||
|
Loading…
Reference in New Issue
Block a user