mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-17 11:04:22 +01:00
update counter too
This commit is contained in:
parent
7abb5921b9
commit
15c268817c
1 changed files with 8 additions and 3 deletions
|
@ -163,9 +163,14 @@ defmodule Philomena.Comments do
|
|||
end
|
||||
|
||||
def migrate_comments(image, duplicate_of_image) do
|
||||
Comment
|
||||
|> where(image_id: ^image.id)
|
||||
|> Repo.update_all(set: [image_id: duplicate_of_image.id])
|
||||
{count, nil} =
|
||||
Comment
|
||||
|> 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)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue