remotes/1693045480750635534/spooky-22
Aevann1 2021-07-26 22:04:23 +02:00
parent 12c4df6e56
commit 96dea77c89
1 changed files with 4 additions and 6 deletions

View File

@ -90,7 +90,6 @@ def api_vote_post(post_id, new, v):
g.db.add(post.author)
existing.vote_type = new
g.db.add(existing)
g.db.commit()
else:
if new != 0:
post.author.dramacoins += 1
@ -101,8 +100,8 @@ def api_vote_post(post_id, new, v):
app_id=v.client.application.id if v.client else None
)
g.db.add(vote)
g.db.commit()
g.db.flush()
post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count()
post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count()
g.db.add(post)
@ -138,7 +137,6 @@ def api_vote_comment(comment_id, new, v):
g.db.add(comment.author)
existing.vote_type = new
g.db.add(existing)
g.db.commit()
else:
if new != 0:
comment.author.dramacoins += 1
@ -150,8 +148,8 @@ def api_vote_comment(comment_id, new, v):
)
g.db.add(vote)
g.db.commit()
g.db.flush()
comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count()
comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count()
g.db.add(comment)