From d1ef92fa17e5e9a90e76ef42a2c02623d1dab219 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 18 Jul 2023 14:38:33 +0300 Subject: [PATCH] fix --- files/routes/votes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/files/routes/votes.py b/files/routes/votes.py index f6e1ea00b3..1f6e717a30 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -138,9 +138,6 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): ) g.db.add(vote) - try: g.db.flush() - except: g.db.rollback() - # this is hacky but it works, we should probably do better later def get_vote_count(dir, real_instead_of_dir): votes = g.db.query(vote_cls) @@ -155,6 +152,10 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): votes = votes.filter(vote_cls.comment_id == target.id) else: return 0 + + try: g.db.flush() + except: g.db.rollback() + return votes.count() target.upvotes = get_vote_count(1, False)