mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
#44 unwrap tag reversions from transaction
This commit is contained in:
parent
6f9955bac1
commit
b54704fba5
1 changed files with 33 additions and 40 deletions
|
@ -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 """
|
||||
|
|
Loading…
Reference in a new issue