From 086e6c378ff11bdaea295215ae9135ad7ffe80cb Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 18 Sep 2021 23:57:16 +0200 Subject: [PATCH] fdsfd --- files/routes/votes.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/files/routes/votes.py b/files/routes/votes.py index 74b74f805..17cd71e97 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -150,9 +150,11 @@ def api_vote_comment(comment_id, new, v): g.db.add(vote) - g.db.flush() - comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count() - comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count() - g.db.add(comment) - g.db.commit() + try: + g.db.flush() + comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count() + comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count() + g.db.add(comment) + g.db.commit() + except: g.db.rolleback() return "", 204 \ No newline at end of file