fix: handle small logic error in notification sending for bulk actions

This commit is contained in:
Zach Daniel 2024-02-25 16:13:41 -05:00
parent 26871fa552
commit 93ae8f17a5
2 changed files with 18 additions and 10 deletions

View file

@ -427,14 +427,18 @@ defmodule Ash.Actions.Destroy.Bulk do
{Enum.reverse(errors), Enum.reverse(successes), notifications, error_count} {Enum.reverse(errors), Enum.reverse(successes), notifications, error_count}
end) end)
else else
{[], results, [], 0} {[], results || [], [], 0}
end end
notifications = notifications =
if opts[:notify?] do
notifications ++ notifications ++
Enum.map(results, fn result -> Enum.map(results, fn result ->
notification(atomic_changeset, result, opts) notification(atomic_changeset, result, opts)
end) end)
else
notifications
end
status = status =
case {error_count, results} do case {error_count, results} do

View file

@ -384,7 +384,7 @@ defmodule Ash.Actions.Update.Bulk do
{Enum.reverse(errors), Enum.reverse(successes), notifications, error_count} {Enum.reverse(errors), Enum.reverse(successes), notifications, error_count}
end) end)
else else
{[], results, [], 0} {[], results || [], [], 0}
end end
{results, errors, error_count} = {results, errors, error_count} =
@ -403,10 +403,14 @@ defmodule Ash.Actions.Update.Bulk do
end end
notifications = notifications =
if opts[:notify?] do
notifications ++ notifications ++
Enum.map(results, fn result -> Enum.map(results, fn result ->
notification(atomic_changeset, result, opts) notification(atomic_changeset, result, opts)
end) end)
else
notifications
end
status = status =
case {error_count, results} do case {error_count, results} do