Update reply counts when deleting profile
This commit is contained in:
parent
c41cb16d23
commit
aa826fd57f
1 changed files with 13 additions and 0 deletions
|
@ -243,6 +243,19 @@ pub async fn delete_profile(
|
||||||
",
|
",
|
||||||
&[&profile_id],
|
&[&profile_id],
|
||||||
).await?;
|
).await?;
|
||||||
|
transaction.execute(
|
||||||
|
"
|
||||||
|
UPDATE post
|
||||||
|
SET reply_count = reply_count - reply.count
|
||||||
|
FROM (
|
||||||
|
SELECT in_reply_to_id, count(*) FROM post
|
||||||
|
WHERE author_id = $1 AND in_reply_to_id IS NOT NULL
|
||||||
|
GROUP BY in_reply_to_id
|
||||||
|
) AS reply
|
||||||
|
WHERE post.id = reply.in_reply_to_id
|
||||||
|
",
|
||||||
|
&[&profile_id],
|
||||||
|
).await?;
|
||||||
// Delete profile
|
// Delete profile
|
||||||
let deleted_count = transaction.execute(
|
let deleted_count = transaction.execute(
|
||||||
"
|
"
|
||||||
|
|
Loading…
Reference in a new issue