Skip to content

Commit

Permalink
improvement: update ash
Browse files Browse the repository at this point in the history
chore: format
  • Loading branch information
zachdaniel committed Apr 26, 2024
1 parent 88c27a5 commit f669243
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
51 changes: 27 additions & 24 deletions lib/ash_json_api/controllers/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ defmodule AshJsonApi.Controllers.Helpers do
)
|> case do
%Ash.BulkResult{status: :success, records: [result | _]} ->
request |> Request.assign(:result, result) |> Request.assign(:record_from_path, result)
request
|> Request.assign(:result, result)
|> Request.assign(:record_from_path, result)

%Ash.BulkResult{status: :success, records: []} ->
error = Error.NotFound.exception(filter: filter, resource: request.resource)
Expand Down Expand Up @@ -228,32 +230,33 @@ defmodule AshJsonApi.Controllers.Helpers do
Request.add_error(request, error, :fetch_from_path)

{:ok, filter, query} ->

query
|> Ash.bulk_destroy(
request.action.name,
%{},
Request.opts(request,
return_errors?: true,
notify?: true,
strategy: [:atomic, :stream, :atomic_batches],
allow_stream_with: :full_read,
return_records?: true,
context: request.context || %{},
load: fields(request, request.resource) ++ (request.includes_keyword || [])
query
|> Ash.bulk_destroy(
request.action.name,
%{},
Request.opts(request,
return_errors?: true,
notify?: true,
strategy: [:atomic, :stream, :atomic_batches],
allow_stream_with: :full_read,
return_records?: true,
context: request.context || %{},
load: fields(request, request.resource) ++ (request.includes_keyword || [])
)
)
)
|> case do
%Ash.BulkResult{status: :success, records: [result | _]} ->
request |> Request.assign(:result, result) |> Request.assign(:record_from_path, result)
|> case do
%Ash.BulkResult{status: :success, records: [result | _]} ->
request
|> Request.assign(:result, result)
|> Request.assign(:record_from_path, result)

%Ash.BulkResult{status: :success, records: []} ->
error = Error.NotFound.exception(filter: filter, resource: request.resource)
Request.add_error(request, error, :fetch_from_path)
%Ash.BulkResult{status: :success, records: []} ->
error = Error.NotFound.exception(filter: filter, resource: request.resource)
Request.add_error(request, error, :fetch_from_path)

%Ash.BulkResult{status: :error, errors: errors} ->
Request.add_error(request, errors, :update)
end
%Ash.BulkResult{status: :error, errors: errors} ->
Request.add_error(request, errors, :update)
end
end
end)
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ defmodule AshJsonApi.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:ash, ash_version("~> 3.0.0-rc.0")},
{:ash, ash_version("~> 3.0.0-rc and >= 3.0.0-rc.31")},
{:plug, "~> 1.11"},
{:jason, "~> 1.1"},
{:json_xema, "~> 0.4"},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%{
"ash": {:hex, :ash, "3.0.0-rc.29", "d62ff46bad2d2bd47bc2c47df88ee0297b8335c4583631f109e5af3f2de6b40e", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, ">= 0.8.1 and < 1.0.0-0", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.1.18 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fa2c508f4fd8ca9cdf10a4c2e101608801a06aed10d6074481e68248d87abd37"},
"ash": {:hex, :ash, "3.0.0-rc.31", "c02d90dc6f127fa80104c07471c7ab3af1a132f1afac16f0ac68811771847545", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, ">= 0.8.1 and < 1.0.0-0", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.1.18 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "93eefaec0a51afa95b60f7a06fb01f62c4483f609ffe27a8d6c053ed9354fdc3"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"comparable": {:hex, :comparable, "1.0.0", "bb669e91cedd14ae9937053e5bcbc3c52bb2f22422611f43b6e38367d94a495f", [:mix], [{:typable, "~> 0.1", [hex: :typable, repo: "hexpm", optional: false]}], "hexpm", "277c11eeb1cd726e7cd41c6c199e7e52fa16ee6830b45ad4cdc62e51f62eb60c"},
"conv_case": {:hex, :conv_case, "0.2.3", "c1455c27d3c1ffcdd5f17f1e91f40b8a0bc0a337805a6e8302f441af17118ed8", [:mix], [], "hexpm", "88f29a3d97d1742f9865f7e394ed3da011abb7c5e8cc104e676fdef6270d4b4a"},
Expand Down

0 comments on commit f669243

Please sign in to comment.