mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
fix: properly load depended on aggregates
improvement: cleaner inspect for calculations
This commit is contained in:
parent
b1afa05026
commit
5b918a0a08
2 changed files with 16 additions and 1 deletions
|
@ -377,7 +377,7 @@ defmodule Ash.Actions.Read do
|
|||
data
|
||||
|> Load.attach_loads(get_in(context, path ++ [:fetch, :load]) || %{})
|
||||
|> add_aggregate_values(
|
||||
query.aggregates,
|
||||
fetched_data[:aggregates],
|
||||
query.resource,
|
||||
get_in(context, path ++ [:aggregate_values]) || %{},
|
||||
Map.get(fetched_data, :aggregates_in_query) || []
|
||||
|
@ -830,6 +830,7 @@ defmodule Ash.Actions.Read do
|
|||
load_paths: load_paths,
|
||||
aggregates_in_query: aggregates_in_query,
|
||||
calculations_at_runtime: calculations_at_runtime,
|
||||
aggregates: ash_query.aggregates,
|
||||
aggregate_value_request_paths:
|
||||
Enum.map(aggregate_value_requests, &(&1.path ++ [:data]))
|
||||
},
|
||||
|
@ -852,6 +853,7 @@ defmodule Ash.Actions.Read do
|
|||
results: request_opts[:initial_data],
|
||||
aggregates_in_query: aggregates_in_query,
|
||||
calculations_at_runtime: calculations_at_runtime,
|
||||
aggregates: ash_query.aggregates,
|
||||
aggregate_value_request_paths:
|
||||
Enum.map(aggregate_value_requests, &(&1.path ++ [:data]))
|
||||
},
|
||||
|
@ -980,6 +982,7 @@ defmodule Ash.Actions.Read do
|
|||
ultimate_query: %{ash_query | filter: filter},
|
||||
count: count,
|
||||
calculations_at_runtime: calculations_at_runtime,
|
||||
aggregates: ash_query.aggregates,
|
||||
aggregates_in_query: aggregates_in_query,
|
||||
aggregate_value_request_paths:
|
||||
Enum.map(aggregate_value_requests, &(&1.path ++ [:data]))
|
||||
|
@ -995,6 +998,7 @@ defmodule Ash.Actions.Read do
|
|||
results: results,
|
||||
count: count,
|
||||
calculations_at_runtime: calculations_at_runtime,
|
||||
aggregates: ash_query.aggregates,
|
||||
aggregates_in_query: aggregates_in_query,
|
||||
aggregate_value_request_paths:
|
||||
Enum.map(aggregate_value_requests, &(&1.path ++ [:data]))
|
||||
|
|
|
@ -56,6 +56,17 @@ defmodule Ash.Query.Calculation do
|
|||
import Inspect.Algebra
|
||||
|
||||
def inspect(%{module: module, opts: calculation_opts, context: context}, _opts) do
|
||||
context =
|
||||
Map.drop(context, [
|
||||
:actor,
|
||||
:authorize?,
|
||||
:filter_requests,
|
||||
:initial_limit,
|
||||
:initial_offset,
|
||||
:context,
|
||||
:ash
|
||||
])
|
||||
|
||||
if context == %{} do
|
||||
module.describe(calculation_opts)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue