diff --git a/files/classes/user.py b/files/classes/user.py index 1cebbd7aa..910fb74a0 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -251,7 +251,7 @@ class User(Base): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.realdownvotes) elif sort == "top": posts = posts.order_by(Submission.realdownvotes - Submission.realupvotes) elif sort == "bottom": diff --git a/files/classes/votes.py b/files/classes/votes.py index 4a95d4e53..2f42956b0 100644 --- a/files/classes/votes.py +++ b/files/classes/votes.py @@ -13,7 +13,7 @@ class Vote(Base): vote_type = Column(Integer) submission_id = Column(Integer, ForeignKey("submissions.id")) app_id = Column(Integer, ForeignKey("oauth_apps.id")) - real = Column(Boolean) + real = Column(Boolean, default=True) user = relationship("User", lazy="subquery", viewonly=True) post = relationship("Submission", lazy="subquery", viewonly=True) @@ -54,7 +54,7 @@ class CommentVote(Base): vote_type = Column(Integer) comment_id = Column(Integer, ForeignKey("comments.id")) app_id = Column(Integer, ForeignKey("oauth_apps.id")) - real = Column(Boolean) + real = Column(Boolean, default=True) user = relationship("User", lazy="subquery", viewonly=True) comment = relationship("Comment", lazy="subquery", viewonly=True) diff --git a/files/routes/comments.py b/files/routes/comments.py index ef78e9bd2..b53ff2533 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -401,7 +401,7 @@ def api_comment(v): g.db.add(n) if v.id == PIZZA_SHILL_ID: - cratvote = CommentVote(user_id=TAX_RECEIVER_ID, comment_id=c.id, vote_type=1, real=True) + cratvote = CommentVote(user_id=TAX_RECEIVER_ID, comment_id=c.id, vote_type=1) g.db.add(cratvote) v.coins += 1 v.truecoins += 1 @@ -585,7 +585,6 @@ def api_comment(v): vote = CommentVote(user_id=v.id, comment_id=c.id, vote_type=1, - real=True ) g.db.add(vote) diff --git a/files/routes/front.py b/files/routes/front.py index 5a5d57f26..88bcf1cbc 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -243,7 +243,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.realdownvotes) elif sort == "top": posts = posts.order_by(Submission.realdownvotes - Submission.realupvotes) elif sort == "bottom": @@ -340,7 +340,7 @@ def changeloglist(v=None, sort="new", page=1 ,t="all"): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.realdownvotes) elif sort == "top": posts = posts.order_by(Submission.realdownvotes - Submission.realupvotes) elif sort == "bottom": @@ -407,7 +407,7 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.realdownvotes) elif sort == "top": comments = comments.order_by(Comment.realdownvotes - Comment.realupvotes) elif sort == "bottom": diff --git a/files/routes/posts.py b/files/routes/posts.py index e112a3a57..b5b5a93e1 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -167,7 +167,7 @@ def post_id(pid, anything=None, v=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.realdownvotes) elif sort == "top": comments = comments.order_by(-Comment.realupvotes - Comment.realdownvotes) elif sort == "bottom": @@ -191,7 +191,7 @@ def post_id(pid, anything=None, v=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.realdownvotes) elif sort == "top": comments = comments.order_by(-Comment.realupvotes - Comment.realdownvotes) elif sort == "bottom": diff --git a/files/routes/search.py b/files/routes/search.py index 282634a1a..e4219e13e 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -131,7 +131,7 @@ def searchposts(v): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.realupvotes * Submission.realdownvotes * Submission.realdownvotes) elif sort == "top": posts = posts.order_by(Submission.realdownvotes - Submission.realupvotes) elif sort == "bottom": @@ -230,7 +230,7 @@ def searchcomments(v): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.realdownvotes) elif sort == "top": comments = comments.order_by(Comment.realdownvotes - Comment.realupvotes) elif sort == "bottom": diff --git a/files/routes/users.py b/files/routes/users.py index 994e74453..f95f75c79 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -690,7 +690,7 @@ def u_username_comments(username, v=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.realupvotes * Comment.realdownvotes * Comment.realdownvotes) elif sort == "top": comments = comments.order_by(Comment.realdownvotes - Comment.realupvotes) elif sort == "bottom": diff --git a/files/routes/votes.py b/files/routes/votes.py index edc020cac..1c2657eed 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -216,7 +216,7 @@ def api_vote_poll(comment_id, v): g.db.add(existing) else: g.db.delete(existing) elif new == 1: - vote = CommentVote(user_id=v.id, vote_type=new, comment_id=comment.id, real=True) + vote = CommentVote(user_id=v.id, vote_type=new, comment_id=comment.id) g.db.add(vote) try: