View Source Plausible.Goals (Plausible v0.0.1)
Summary
Functions
Creates a Goal for a site.
If a goal belongs to funnel(s), we need to inspect their number of steps.
Functions
@spec count(Plausible.Site.t()) :: non_neg_integer()
@spec create(Plausible.Site.t(), map(), Keyword.t()) :: {:ok, Plausible.Goal.t()} | {:error, Ecto.Changeset.t()} | {:error, :upgrade_required}
Creates a Goal for a site.
If the created goal is a revenue goal, it sets site.updated_at to be refreshed by the sites cache, as revenue goals are used during ingestion.
If a goal belongs to funnel(s), we need to inspect their number of steps.
If it exceeds the minimum allowed (defined via Plausible.Funnel.min_steps/0
),
the funnel will be reduced (i.e. a step associated with the goal to be deleted
is removed), so that the minimum number of steps is preserved. This is done
implicitly, by postgres, as per on_delete: :delete_all.
Otherwise, for associated funnel(s) consisting of minimum number steps only, funnel record(s) are removed completely along with the targeted goal.
@spec get(Plausible.Site.t(), pos_integer()) :: nil | Plausible.Goal.t()
@spec update(Plausible.Goal.t(), map()) :: {:ok, Plausible.Goal.t()} | {:error, Ecto.Changeset.t()} | {:error, :upgrade_required}