From bea5f5e8d74102dd62245a235253b0b48b961ae9 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 20 Sep 2021 21:39:42 +0200 Subject: [PATCH] dfsfs --- 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 84f96671a..15a64c1a1 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -96,11 +96,13 @@ def api_vote_post(post_id, new, v): ) g.db.add(vote) - g.db.flush() - post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count() - post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count() - g.db.add(post) - g.db.commit() + try: + g.db.flush() + post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count() + post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count() + g.db.add(post) + g.db.commit() + except: g.db.rollback() return "", 204 @app.post("/vote/comment//")