Recalc community.post_reply_count after replies are purged as part of a post purge

This commit is contained in:
freamon 2024-10-26 04:46:51 +00:00
parent 502e6ff0f6
commit d738850fc7

View file

@ -1387,6 +1387,9 @@ class Post(db.Model):
db.session.execute(text('DELETE FROM "report" WHERE suspect_post_reply_id IN :reply_ids'), {'reply_ids': reply_ids})
db.session.execute(text('DELETE FROM "post_reply" WHERE post_id = :post_id'), {'post_id': self.id})
self.community.post_reply_count = db.session.execute(text('SELECT COUNT(id) as c FROM "post_reply" WHERE community_id = :community_id AND deleted = false'),
{'community_id': self.community_id}).scalar()
if self.image_id:
file = File.query.get(self.image_id)
file.delete_from_disk()