View Source ExTeal.Metric.Trend behaviour (ExTeal v0.28.1)

Trend metrics display the trend of a computed aggregate over a range of time. For example, a trend metric might display the count of new users created every day for the last thirty days.

A Trend metric offers the ability to chose both the range of time that is being displayed and the granularity of results. The granularity is stored as as the unit singluar while the ranges includes all available units.

The available units are:

  • year
  • month
  • week
  • day
  • hour
  • minute

Some of these data sets will be rather large, so we should provide some safe defaults for the maximum number of results returned.

Summary

Types

@type multi_result() :: map()
@type result() :: map()
@type valid_result() :: result() | [multi_result()]

Callbacks

@callback calculate(ExTeal.Metric.Request.t()) :: valid_result()
@callback cast(Decimal.t()) :: any()
@callback precision() :: integer()
@callback twelve_hour_time() :: boolean()

Functions

Link to this function

aggregate(metric, request, query, aggregate_type, field, series_options)

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

aggregate_as(query, atom, f)

View Source
@spec aggregate_as(Ecto.Queryable.t(), atom(), atom()) :: Ecto.Queryable.t()

Build a select for the field and aggregate type

Link to this function

format_result_data(map, unit, timezone)

View Source
@spec format_result_data(map(), String.t(), String.t()) :: {String.t(), number()}

Takes a database record transforms it into a two-tuple of the date_result parsed into an appropriate format

Link to this function

get_possible_results(start_dt, end_dt, request, timezone)

View Source
Link to this function

to_local_dt(db_date, format, timezone)

View Source
@spec to_local_dt(String.t(), String.t(), String.t()) :: DateTime.t()
Link to this function

to_result_date(datetime)

View Source
@spec to_result_date(DateTime.t()) :: String.t()