From c652be402486b73641af36499d89f59ea2d881e8 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Wed, 1 Jan 2025 15:58:28 +1300 Subject: [PATCH] more efficient query than the one generated by sqlalchemy --- app/cli.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/cli.py b/app/cli.py index 6c0ad488..48c3d168 100644 --- a/app/cli.py +++ b/app/cli.py @@ -210,8 +210,7 @@ def register(app): {'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_id': community.id}).scalar() - - db.session.commit() + db.session.commit() # Delete voting data after 6 months db.session.execute(text('DELETE FROM "post_vote" WHERE created_at < :cutoff'), {'cutoff': utcnow() - timedelta(days=28 * 6)})