Skip to content

Commit

Permalink
fix: Invalid Typespecs from default functions on Trend Metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
staylorwr committed May 21, 2021
1 parent 836de32 commit 0eb02fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/ex_teal/metric/metric.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule ExTeal.Metric do
}

@callback date_field() :: atom()
@callback date_field_type() :: :naive_date_time | :utc_datetime
@callback date_field_type() :: :naive_datetime | :utc_datetime
@callback multiple_results() :: boolean()

@doc """
Expand Down Expand Up @@ -47,12 +47,12 @@ defmodule ExTeal.Metric do
@doc """
A string to prepend to any displayed value on the metric card. For example: `$`
"""
@callback prefix() :: String.t()
@callback prefix() :: String.t() | nil

@doc """
A string to appended to any displayed value on the metric card. For example: `°`
"""
@callback suffix() :: String.t()
@callback suffix() :: String.t() | nil

@doc """
A string representing how a value is formatted before being displayed by the
Expand Down
4 changes: 4 additions & 0 deletions lib/ex_teal/metric/ranges.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ defmodule ExTeal.Metric.Ranges do
utc = Timezone.get("Etc/UTC", value)
Timezone.convert(value, utc)
end

defp to_dt_field_type(value, :utc_datetime) do
value
end
end
6 changes: 4 additions & 2 deletions lib/ex_teal/metric/trend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ defmodule ExTeal.Metric.Trend do
defaults for the maximum number of results returned.
"""

@type result :: map()

@type multi_result :: map()

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

@callback twelve_hour_time() :: boolean()

Expand Down Expand Up @@ -104,7 +106,7 @@ defmodule ExTeal.Metric.Trend do
import ExTeal.Metric.Ranges
alias ExTeal.Metric.{Request, TrendExpressionFactory}

@spec aggregate(module(), Request.t(), Ecto.Queryable.t(), atom(), atom(), map()) :: map()
@spec aggregate(module(), Request.t(), Ecto.Queryable.t(), atom(), atom(), map()) :: result()
def aggregate(metric, request, query, aggregate_type, field, series_options) do
{start_dt, end_dt} = get_aggregate_datetimes(request)
timezone = start_dt.time_zone
Expand Down

0 comments on commit 0eb02fd

Please sign in to comment.