action :country_stats do
run fn input, context ->
{:ok, query} =
User
|> Ash.Query.to_query()
|> Ash.Query.data_layer_query()
result =
from(user in query,
select: {user.country_code, count(user.country_code)},
group_by: user.country_code,
)
|> Repo.all()
|> Map.new()
{:ok, result}
end
end
action :country_stats do
run fn input, context ->
{:ok, query} =
User
|> Ash.Query.to_query()
|> Ash.Query.data_layer_query()
result =
from(user in query,
select: {user.country_code, count(user.country_code)},
group_by: user.country_code,
)
|> Repo.all()
|> Map.new()
{:ok, result}
end
end