mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
reduce cpu usage of daily-maintenance task
This commit is contained in:
parent
ab217dc318
commit
3871691ea4
1 changed files with 2 additions and 1 deletions
|
@ -205,7 +205,8 @@ def register(app):
|
||||||
|
|
||||||
# Ensure accurate community stats
|
# Ensure accurate community stats
|
||||||
for community in Community.query.filter(Community.banned == False).all():
|
for community in Community.query.filter(Community.banned == False).all():
|
||||||
community.subscriptions_count = CommunityMember.query.filter(CommunityMember.community_id == community.id).count()
|
community.subscriptions_count = db.session.execute(text('SELECT COUNT(user_id) as c FROM community_member WHERE community_id = :community_id AND is_banned = false'),
|
||||||
|
{'community_id': community.id}).scalar()
|
||||||
community.post_count = db.session.execute(text('SELECT COUNT(id) as c FROM post WHERE deleted is false and community_id = :community_id'),
|
community.post_count = db.session.execute(text('SELECT COUNT(id) as c FROM post WHERE deleted is false and community_id = :community_id'),
|
||||||
{'community_id': community.id}).scalar()
|
{'community_id': community.id}).scalar()
|
||||||
community.post_reply_count = db.session.execute(text('SELECT COUNT(id) as c FROM post_reply WHERE deleted is false and community_id = :community_id'),
|
community.post_reply_count = db.session.execute(text('SELECT COUNT(id) as c FROM post_reply WHERE deleted is false and community_id = :community_id'),
|
||||||
|
|
Loading…
Add table
Reference in a new issue