Behaviour for a single analysis capability (frequency, aggregate, time_bucket, percentile, histogram, ...).
AshDyan's analysis types were previously a closed sum type scattered across
parallel case/when clauses in AshDyan.Request, AshDyan.Engine,
AshDyan.Engine.Formatter, and AshDyan.Charts. Implementing this behaviour
and registering the module under config :ash_dyan, :analysis_types lets a
downstream app add a new analysis type (e.g. :funnel, :cohort) without
forking AshDyan.
Example
defmodule MyApp.AshDyan.Funnel do
@behaviour AshDyan.Analysis
# ... implement the callbacks ...
end
# config/config.exs
config :ash_dyan, :analysis_types, %{funnel: MyApp.AshDyan.Funnel}The request's :type is the registry key.
Summary
Types
@type query() :: Ash.Query.t()
@type records() :: [Ash.Resource.Record.t()]
@type request() :: AshDyan.Request.t()
@type result() :: AshDyan.Result.t()
Callbacks
@callback recommend_chart(result()) :: AshDyan.Charts.chart_type()
@callback validate(request()) :: :ok | {:error, AshDyan.Error.t()}