#44 unwrap tag reversions from transaction

This commit is contained in:
byte[] 2020-05-06 10:40:23 -04:00
parent 6f9955bac1
commit b54704fba5

View file

@ -44,7 +44,6 @@ defmodule Philomena.TagChanges do
to_add = Enum.map(removed, &%{image_id: &1.image_id, tag_id: &1.tag_id})
Repo.transaction(fn ->
{_count, inserted} =
Repo.insert_all(Tagging, to_add, on_conflict: :nothing, returning: [:image_id, :tag_id])
@ -87,16 +86,10 @@ defmodule Philomena.TagChanges do
upserts = added_upserts ++ removed_upserts
Repo.insert_all(Tag, upserts, on_conflict: update_query, conflict_target: [:id])
end)
|> case do
{:ok, _result} ->
Images.reindex_images(image_ids)
{:ok, tag_changes}
error ->
error
end
end
@doc """