View Source ExTeal.Metric.Value behaviour (ExTeal v0.27.0)

Value Metrics display a single value and it's change compared to a previous interval of time. For example, a value metric might display the total number of blog posts created in the last thirty days, versus the previous thirty days.

Once generated, a value metric module has two functions that can be customized, a calculate/1 and a ranges/0 function.

Additionally there are modifier functions that change the behavior and display of the metric.

Summary

Types

@type multi_result() :: [%{label: String.t(), data: result()}]
@type result() :: %{current: term(), previous: term()}
@type valid_result() :: result() | [multi_result()]

Callbacks

Functions

Link to this function

aggregate(metric_module, request, queryable, aggregate_type, field)

View Source
@spec aggregate(
  module(),
  ExTeal.Metric.Request.t(),
  Ecto.Queryable.t(),
  atom(),
  atom()
) :: map()
Link to this function

between_current(query, atom, options)

View Source
Link to this function

query_for(current, metric, request, queryable, aggregate_type, field)

View Source
@spec query_for(
  atom(),
  module(),
  ExTeal.Metric.Request.t(),
  Ecto.Queryable.t(),
  atom(),
  atom()
) ::
  integer() | float()