Lotus.Web.Dashboards.CardVariables (Lotus Web v1.2.0)

Copy Markdown View Source

Builds the query variables of a dashboard card with Lotus.card_variables/4, the rule Lotus.Dashboards.run_dashboard_card/2 uses: the filter value or else the default value, the relative date token resolved against today, and the transform of each mapping.

The dashboard pages run cards themselves, for bounded concurrency, cancellation and a :query check per card, so they cannot call run_dashboard_card/2. They call build/4 with one today per run.

A card has its mappings in one of two forms:

  • the %Lotus.Storage.DashboardCardFilterMapping{} structs of a saved card
  • the map the dashboard editor keeps while a card changes, %{filter_name => [%{variable_name: name, transform: transform}]}

Summary

Functions

Returns the vars for a card with mappings on a dashboard with filters.

Types

entry()

@type entry() :: %{variable_name: String.t() | nil, transform: map() | nil}

mappings()

@type mappings() :: [struct()] | %{optional(String.t()) => [entry()]}

Functions

build(mappings, filters, filter_values, today)

@spec build(mappings() | nil, [map()], map(), Date.t()) :: %{
  optional(String.t()) => term()
}

Returns the vars for a card with mappings on a dashboard with filters.