Skip to content

Commit

Permalink
improvement: speed up type loading
Browse files Browse the repository at this point in the history
improvement: add `__order__` field to be used by data layers
chore: fix typespec for aggregates
  • Loading branch information
zachdaniel committed Jul 19, 2021
1 parent f221600 commit 42aa562
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ash/resource/aggregate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Ash.Resource.Aggregate do

@type t :: %__MODULE__{
name: atom(),
relationship_path: {:ok, list(atom())} | {:error, String.t()},
relationship_path: list(atom()),
filter: Keyword.t(),
field: atom,
kind: :count | :first | :sum | :list,
Expand Down
2 changes: 2 additions & 0 deletions lib/ash/resource/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ defmodule Ash.Schema do
field(:aggregates, :map, virtual: true, default: %{})
field(:calculations, :map, virtual: true, default: %{})
field(:__metadata__, :map, virtual: true, default: %{}, redact: true)
field(:__order__, :integer, virtual: true)

for aggregate <- Ash.Resource.Info.aggregates(__MODULE__) do
{:ok, type} = Aggregate.kind_to_type(aggregate.kind, :string)
Expand Down Expand Up @@ -87,6 +88,7 @@ defmodule Ash.Schema do
field(:aggregates, :map, virtual: true, default: %{})
field(:calculations, :map, virtual: true, default: %{})
field(:__metadata__, :map, virtual: true, default: %{}, redact: true)
field(:__order__, :integer, virtual: true)

for aggregate <- Ash.Resource.Info.aggregates(__MODULE__) do
{:ok, type} = Aggregate.kind_to_type(aggregate.kind, :string)
Expand Down
1 change: 0 additions & 1 deletion lib/ash/type/type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ defmodule Ash.Type do
end

def cast_stored(type, term, constraints) do
type = get_type(type)
type.cast_stored(term, constraints)
end

Expand Down

0 comments on commit 42aa562

Please sign in to comment.