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

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.

Link to this section Summary

Link to this section Types

Specs

multi_result() :: map()

Specs

result() :: map()

Specs

valid_result() :: result() | [multi_result()]

Link to this section Callbacks

Specs

Specs

cast(Decimal.t()) :: any()

Specs

precision() :: integer()

Specs

twelve_hour_time() :: boolean()

Link to this section Functions

Link to this function

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

View Source

Specs

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

aggregate_as(query, atom, f)

View Source

Specs

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

Specs

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

Specs

to_local_dt(String.t(), String.t(), String.t()) :: DateTime.t()
Link to this function

to_result_date(datetime)

View Source

Specs

to_result_date(DateTime.t()) :: String.t()