Fix
This commit is contained in:
parent
7df19883b1
commit
c9791acff8
1 changed files with 8 additions and 2 deletions
|
@ -25,10 +25,16 @@ defmodule ChoreTracker.Chores do
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_chore(%Chore{} = chore, attrs) do
|
def update_chore(%Chore{} = chore, attrs) do
|
||||||
|
changeset = change_chore(chore, attrs)
|
||||||
|
|
||||||
Ecto.Multi.new()
|
Ecto.Multi.new()
|
||||||
|> Ecto.Multi.update(:chore, change_chore(chore, attrs))
|
|> Ecto.Multi.update(:chore, changeset)
|
||||||
|> Ecto.Multi.run(:update_next_assignee, fn _repo, %{chore: chore} ->
|
|> Ecto.Multi.run(:update_next_assignee, fn _repo, %{chore: chore} ->
|
||||||
|
if Ecto.Changeset.changed?(changeset, :assignees) do
|
||||||
save_next_chore_assignee(chore)
|
save_next_chore_assignee(chore)
|
||||||
|
else
|
||||||
|
{:ok, chore}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|> Repo.transaction()
|
|> Repo.transaction()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue