diff --git a/drama/classes/mix_ins.py b/drama/classes/mix_ins.py index 4d2bd8aa9..85313a7a2 100644 --- a/drama/classes/mix_ins.py +++ b/drama/classes/mix_ins.py @@ -122,10 +122,6 @@ class Scores: @property #@cache.memoize(timeout=60) def score_percent(self): - # try: - # return int((self.ups/(self.ups+self.downs))*100) - # except ZeroDivisionError: - # return 0 return 101 diff --git a/drama/routes/front.py b/drama/routes/front.py index aa23b5182..930cb9e6b 100644 --- a/drama/routes/front.py +++ b/drama/routes/front.py @@ -164,8 +164,8 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words='' g.db.add(vote) try: g.db.flush() except: g.db.rollback() - post.upvotes = post.ups - post.downvotes = post.downs + 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() post.views = post.views + random.randint(7,10) g.db.add(post) diff --git a/drama/routes/posts.py b/drama/routes/posts.py index 53a6b42b3..dd260d180 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -194,8 +194,8 @@ def post_base36id(pid, anything=None, v=None): g.db.add(vote) try: g.db.flush() except: g.db.rollback() - comment.upvotes = comment.ups - comment.downvotes = comment.downs + 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) post._preloaded_comments = [x for x in comments if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)] @@ -971,8 +971,6 @@ def submit_post(v): user = get_account(follow.user_id) send_notification(2360, user, f"@{v.username} has made a new post: [{title}](https://rdrama.net{new_post.permalink})") - new_post.upvotes = new_post.ups - new_post.downvotes = new_post.downs g.db.add(new_post) g.db.commit() diff --git a/drama/routes/votes.py b/drama/routes/votes.py index 18e9ad30b..e40d62896 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -117,8 +117,8 @@ def api_vote_post(post_id, x, v): g.db.flush() - post.upvotes = g.db.query(Vote).filter_by(comment_id=comment.id, vote_type=1).count() - post.downvotes = g.db.query(Vote).filter_by(comment_id=comment.id, vote_type=-1).count() + 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) return "", 204 diff --git a/drama/templates/submission_banned.html b/drama/templates/submission_banned.html index e4ae781b7..f33000465 100644 --- a/drama/templates/submission_banned.html +++ b/drama/templates/submission_banned.html @@ -44,7 +44,7 @@ {% endif %} {% endif %} -

Score: +{{p.ups}}/-{{p.downs}}

+

Score: +{{p.upvotes}}/-{{p.downvotes}}

{% endblock %} {% block content %}