From 0ce036e13a6795e4419ac1ea855b11af9548a34e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 1 Dec 2021 01:21:29 +0200 Subject: [PATCH] dfdf --- files/classes/user.py | 6 +++--- files/routes/front.py | 20 ++++++++++---------- files/routes/posts.py | 12 ++++++------ files/routes/search.py | 12 ++++++------ files/routes/users.py | 6 +++--- files/routes/votes.py | 4 ++-- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index f17d69b46..a80342e47 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -251,11 +251,11 @@ 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.downvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) elif sort == "top": - posts = posts.order_by(Submission.downvotes - Submission.realupvotes) + posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": - posts = posts.order_by(Submission.realupvotes - Submission.downvotes) + posts = posts.order_by(Submission.upvotes - Submission.downvotes) elif sort == "comments": posts = posts.order_by(Submission.comment_count.desc()) diff --git a/files/routes/front.py b/files/routes/front.py index dc2e1fcbf..93fb90588 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -237,17 +237,17 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' if sort == "hot": ti = int(time.time()) + 3600 - posts = posts.order_by(-1000000*(Submission.realupvotes + Submission.downvotes + 1 + Submission.comment_count/5)/(func.power(((ti - Submission.created_utc)/1000), 1.35))) + posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5)/(func.power(((ti - Submission.created_utc)/1000), 1.35))) elif sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.realupvotes * Submission.downvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) elif sort == "top": - posts = posts.order_by(Submission.downvotes - Submission.realupvotes) + posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": - posts = posts.order_by(Submission.realupvotes - Submission.downvotes) + posts = posts.order_by(Submission.upvotes - Submission.downvotes) elif sort == "comments": posts = posts.order_by(Submission.comment_count.desc()) @@ -340,11 +340,11 @@ 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.downvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) elif sort == "top": - posts = posts.order_by(Submission.downvotes - Submission.realupvotes) + posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": - posts = posts.order_by(Submission.realupvotes - Submission.downvotes) + posts = posts.order_by(Submission.upvotes - Submission.downvotes) elif sort == "comments": posts = posts.order_by(Submission.comment_count.desc()) @@ -407,11 +407,11 @@ 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.downvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) elif sort == "top": - comments = comments.order_by(Comment.downvotes - Comment.realupvotes) + comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": - comments = comments.order_by(Comment.realupvotes - Comment.downvotes) + comments = comments.order_by(Comment.upvotes - Comment.downvotes) comments = comments.offset(25 * (page - 1)).limit(26).all() return [x[0] for x in comments] diff --git a/files/routes/posts.py b/files/routes/posts.py index 195a13733..9bda08cde 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -167,11 +167,11 @@ 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.downvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) elif sort == "top": - comments = comments.order_by(-Comment.realupvotes - Comment.downvotes) + comments = comments.order_by(-Comment.upvotes - Comment.downvotes) elif sort == "bottom": - comments = comments.order_by(Comment.realupvotes - Comment.downvotes) + comments = comments.order_by(Comment.upvotes - Comment.downvotes) output = [] for c in comments.all(): @@ -191,11 +191,11 @@ 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.downvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) elif sort == "top": - comments = comments.order_by(-Comment.realupvotes - Comment.downvotes) + comments = comments.order_by(-Comment.upvotes - Comment.downvotes) elif sort == "bottom": - comments = comments.order_by(Comment.realupvotes - Comment.downvotes) + comments = comments.order_by(Comment.upvotes - Comment.downvotes) post.replies = comments.filter(Comment.is_pinned != None).all() + comments.filter(Comment.level == 1, Comment.is_pinned == None).all() diff --git a/files/routes/search.py b/files/routes/search.py index 0bbe3fbd5..99d4f38a0 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -131,11 +131,11 @@ 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.downvotes * Submission.downvotes) + posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) elif sort == "top": - posts = posts.order_by(Submission.downvotes - Submission.realupvotes) + posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": - posts = posts.order_by(Submission.realupvotes - Submission.downvotes) + posts = posts.order_by(Submission.upvotes - Submission.downvotes) elif sort == "comments": posts = posts.order_by(Submission.comment_count.desc()) @@ -230,11 +230,11 @@ 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.downvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) elif sort == "top": - comments = comments.order_by(Comment.downvotes - Comment.realupvotes) + comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": - comments = comments.order_by(Comment.realupvotes - Comment.downvotes) + comments = comments.order_by(Comment.upvotes - Comment.downvotes) total = comments.count() diff --git a/files/routes/users.py b/files/routes/users.py index 5cc62e9e6..2f9aa8b5c 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -690,11 +690,11 @@ 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.downvotes * Comment.downvotes) + comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) elif sort == "top": - comments = comments.order_by(Comment.downvotes - Comment.realupvotes) + comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": - comments = comments.order_by(Comment.realupvotes - Comment.downvotes) + comments = comments.order_by(Comment.upvotes - Comment.downvotes) comments = comments.offset(25 * (page - 1)).limit(26).all() ids = [x.id for x in comments] diff --git a/files/routes/votes.py b/files/routes/votes.py index 23a260680..c4cd8c4d7 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -119,7 +119,7 @@ def api_vote_post(post_id, new, v): g.db.flush() post.upvotes = g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=1).count() post.downvotes = g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=-1).count() - post.realupvotes = g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=1, real=True).count() + post.realupvotes = g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=1, real=True).count() - g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=1, real=False).count() - g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=-1, real=True).count() + g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=-1, real=False).count() g.db.add(post) g.db.commit() except: g.db.rollback() @@ -187,7 +187,7 @@ def api_vote_comment(comment_id, new, v): g.db.flush() comment.upvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=1).count() comment.downvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=-1).count() - comment.realupvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=1, real=True).count() + comment.realupvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, CommentVote_type=1, real=True).count() - g.db.query(CommentVote.id).filter_by(comment_id=comment.id, CommentVote_type=1, real=False).count() - g.db.query(CommentVote.id).filter_by(comment_id=comment.id, CommentVote_type=-1, real=True).count() + g.db.query(CommentVote.id).filter_by(comment_id=comment.id, CommentVote_type=-1, real=False).count() g.db.add(comment) g.db.commit() except: g.db.rollback()