diff --git a/files/classes/user.py b/files/classes/user.py index e55c6e7c08..10d3f3458d 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -288,7 +288,7 @@ class User(Base): if sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": - posts = posts.order_by(Submission.created_utc.asc()) + posts = posts.order_by(Submission.created_utc) elif sort == "controversial": posts = posts.order_by((Submission.upvotes+1)/(Submission.downvotes+1) + (Submission.downvotes+1)/(Submission.upvotes+1), Submission.downvotes.desc()) elif sort == "top": @@ -444,7 +444,7 @@ class User(Base): ) ).filter( User.id != self.id - ).order_by(User.username.asc()).all() + ).order_by(User.username).all() data = [x for x in data] output = [] diff --git a/files/routes/front.py b/files/routes/front.py index 66ec3faf38..40741f4620 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -331,25 +331,21 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" if sort == "hot": ti = int(time.time()) + 3600 - posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5 + (func.length(Submission.body_html)-func.length(func.replace(Submission.body_html,'',''))))/(func.power(((ti - Submission.created_utc)/1000), 1.23))) - - if v and v.id == AEVANN_ID: - for p in posts: - print(-1000000*(p.realupvotes + 1 + p.comment_count/5 + (len(p.body_html)-len(p.body_html.replace('',''))))/((ti - p.created_utc)/1000)**1.23, flush=True) + posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5 + (func.length(Submission.body_html)-func.length(func.replace(Submission.body_html,'',''))))/(func.power(((ti - Submission.created_utc)/1000), 1.23)), Submission.created_utc.desc()) elif sort == "bump": - posts = posts.filter(Submission.comment_count > 1).order_by(Submission.bump_utc.desc()) + posts = posts.filter(Submission.comment_count > 1).order_by(Submission.bump_utc.desc(), Submission.created_utc.desc()) elif sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": - posts = posts.order_by(Submission.created_utc.asc()) + posts = posts.order_by(Submission.created_utc) elif sort == "controversial": - posts = posts.order_by((Submission.upvotes+1)/(Submission.downvotes+1) + (Submission.downvotes+1)/(Submission.upvotes+1), Submission.downvotes.desc()) + posts = posts.order_by((Submission.upvotes+1)/(Submission.downvotes+1) + (Submission.downvotes+1)/(Submission.upvotes+1), Submission.downvotes.desc(), Submission.created_utc.desc()) elif sort == "top": - posts = posts.order_by(Submission.downvotes - Submission.upvotes) + posts = posts.order_by(Submission.downvotes - Submission.upvotes, Submission.created_utc.desc()) elif sort == "bottom": - posts = posts.order_by(Submission.upvotes - Submission.downvotes) + posts = posts.order_by(Submission.upvotes - Submission.downvotes, Submission.created_utc.desc()) elif sort == "comments": - posts = posts.order_by(Submission.comment_count.desc()) + posts = posts.order_by(Submission.comment_count.desc(), Submission.created_utc.desc()) if v: size = v.frontsize or 0 else: size = 25 @@ -449,7 +445,7 @@ def changeloglist(v=None, sort="new", page=1 ,t="all"): if sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": - posts = posts.order_by(Submission.created_utc.asc()) + posts = posts.order_by(Submission.created_utc) elif sort == "controversial": posts = posts.order_by((Submission.upvotes+1)/(Submission.downvotes+1) + (Submission.downvotes+1)/(Submission.upvotes+1), Submission.downvotes.desc()) elif sort == "top": @@ -509,7 +505,7 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"): if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) elif sort == "old": - comments = comments.order_by(Comment.created_utc.asc()) + comments = comments.order_by(Comment.created_utc) elif sort == "controversial": comments = comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc()) elif sort == "top": diff --git a/files/routes/posts.py b/files/routes/posts.py index 7be760b405..93cafb7d2c 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -189,7 +189,7 @@ def post_id(pid, anything=None, v=None, sub=None): if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) elif sort == "old": - comments = comments.order_by(Comment.created_utc.asc()) + comments = comments.order_by(Comment.created_utc) elif sort == "controversial": comments = comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc()) elif sort == "top": @@ -208,7 +208,7 @@ def post_id(pid, anything=None, v=None, sub=None): if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) elif sort == "old": - comments = comments.order_by(Comment.created_utc.asc()) + comments = comments.order_by(Comment.created_utc) elif sort == "controversial": comments = comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc()) elif sort == "top": @@ -317,7 +317,7 @@ def viewmore(v, pid, sort, offset): if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) elif sort == "old": - comments = comments.order_by(Comment.created_utc.asc()) + comments = comments.order_by(Comment.created_utc) elif sort == "controversial": comments = comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc()) elif sort == "top": @@ -334,7 +334,7 @@ def viewmore(v, pid, sort, offset): if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) elif sort == "old": - comments = comments.order_by(Comment.created_utc.asc()) + comments = comments.order_by(Comment.created_utc) elif sort == "controversial": comments = comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc()) elif sort == "top": diff --git a/files/routes/search.py b/files/routes/search.py index d730ee5588..f7bbd1d82d 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -136,7 +136,7 @@ def searchposts(v): if sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": - posts = posts.order_by(Submission.created_utc.asc()) + posts = posts.order_by(Submission.created_utc) elif sort == "controversial": posts = posts.order_by((Submission.upvotes+1)/(Submission.downvotes+1) + (Submission.downvotes+1)/(Submission.upvotes+1), Submission.downvotes.desc()) elif sort == "top": @@ -250,7 +250,7 @@ def searchcomments(v): if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) elif sort == "old": - comments = comments.order_by(Comment.created_utc.asc()) + comments = comments.order_by(Comment.created_utc) elif sort == "controversial": comments = comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc()) elif sort == "top": diff --git a/files/routes/users.py b/files/routes/users.py index 3f67feb4cd..6da935e95c 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -766,7 +766,7 @@ def u_username_comments(username, v=None): if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) elif sort == "old": - comments = comments.order_by(Comment.created_utc.asc()) + comments = comments.order_by(Comment.created_utc) elif sort == "controversial": comments = comments.order_by((Comment.upvotes+1)/(Comment.downvotes+1) + (Comment.downvotes+1)/(Comment.upvotes+1), Comment.downvotes.desc()) elif sort == "top":