update counter too

This commit is contained in:
byte[] 2019-12-21 20:31:25 -05:00
parent 7abb5921b9
commit 15c268817c

View file

@ -163,9 +163,14 @@ defmodule Philomena.Comments do
end end
def migrate_comments(image, duplicate_of_image) do def migrate_comments(image, duplicate_of_image) do
Comment {count, nil} =
|> where(image_id: ^image.id) Comment
|> Repo.update_all(set: [image_id: duplicate_of_image.id]) |> where(image_id: ^image.id)
|> Repo.update_all(set: [image_id: duplicate_of_image.id])
Image
|> where(id: ^duplicate_of_image.id)
|> Repo.update_all(inc: [comments_count: count])
reindex_comments(duplicate_of_image) reindex_comments(duplicate_of_image)
end end