This commit is contained in:
Aevann1 2021-09-20 21:39:42 +02:00
parent d504c6eb25
commit b74946da3b

View file

@ -96,11 +96,13 @@ def api_vote_post(post_id, new, v):
) )
g.db.add(vote) g.db.add(vote)
try:
g.db.flush() g.db.flush()
post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count() 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() post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count()
g.db.add(post) g.db.add(post)
g.db.commit() g.db.commit()
except: g.db.rollback()
return "", 204 return "", 204
@app.post("/vote/comment/<comment_id>/<new>") @app.post("/vote/comment/<comment_id>/<new>")