mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Ensure accurate community stats
This commit is contained in:
parent
c2fa5fc416
commit
0d3b184238
1 changed files with 6 additions and 0 deletions
|
@ -204,6 +204,12 @@ def register(app):
|
||||||
db.session.delete(post)
|
db.session.delete(post)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
# Ensure accurate community stats
|
||||||
|
for community in Community.query.filter(Community.banned == False).all():
|
||||||
|
community.post_count = community.posts.filter(Post.deleted == False).count()
|
||||||
|
community.post_reply_count = community.replies.filter(PostReply.deleted == False).count()
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
# Delete voting data after 6 months
|
# Delete voting data after 6 months
|
||||||
db.session.execute(text('DELETE FROM "post_vote" WHERE created_at < :cutoff'), {'cutoff': utcnow() - timedelta(days=28 * 6)})
|
db.session.execute(text('DELETE FROM "post_vote" WHERE created_at < :cutoff'), {'cutoff': utcnow() - timedelta(days=28 * 6)})
|
||||||
db.session.execute(text('DELETE FROM "post_reply_vote" WHERE created_at < :cutoff'), {'cutoff': utcnow() - timedelta(days=28 * 6)})
|
db.session.execute(text('DELETE FROM "post_reply_vote" WHERE created_at < :cutoff'), {'cutoff': utcnow() - timedelta(days=28 * 6)})
|
||||||
|
|
Loading…
Reference in a new issue