From e5f018ff393954f9382f1e1e8422cce165798d45 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 6 Aug 2021 14:47:25 +0200 Subject: [PATCH] fd --- files/classes/user.py | 4 ++-- files/routes/front.py | 4 ++-- files/routes/search.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index d274a622c..a1e29954a 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -135,7 +135,7 @@ class User(Base, Stndrd, Age_times): @property @lazy def referral_count(self): - return self.referrals.count() + return len(self.referrals) def has_block(self, target): @@ -196,7 +196,7 @@ class User(Base, Stndrd, Age_times): elif sort == "bottom": submissions = sorted(submissions.all(), key=lambda x: x.score) elif sort == "comments": - submissions = submissions.order_by(Submission.comment_count.desc()).all() + submissions = sorted(submissions.all(), key=lambda x: x.comment_count, reverse=True) firstrange = 25 * (page - 1) secondrange = firstrange + 26 diff --git a/files/routes/front.py b/files/routes/front.py index 6a865a046..75226ea5a 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -130,7 +130,7 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words='' elif sort == "bottom": posts = sorted(posts.all(), key=lambda x: x.score) elif sort == "comments": - posts = posts.order_by(Submission.comment_count.desc()).all() + posts = sorted(posts.all(), key=lambda x: x.comment_count, reverse=True) elif sort == "random": posts = posts.all() posts = random.sample(posts, k=len(posts)) @@ -274,7 +274,7 @@ def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs): elif sort == "bottom": posts = sorted(posts.all(), key=lambda x: x.score) elif sort == "comments": - posts = posts.order_by(Submission.comment_count.desc()).all() + posts = sorted(posts.all(), key=lambda x: x.comment_count, reverse=True) elif sort == "random": posts = posts.all() posts = random.sample(posts, k=len(posts)) diff --git a/files/routes/search.py b/files/routes/search.py index a6b1c168f..efacf8d4c 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -128,7 +128,7 @@ def searchlisting(criteria, v=None, page=1, t="None", sort="top", b=None): elif sort == "bottom": posts = sorted(posts.all(), key=lambda x: x.score) elif sort == "comments": - posts = posts.order_by(Submission.comment_count.desc()).all() + posts = sorted(posts.all(), key=lambda x: x.comment_count, reverse=True) elif sort == "random": posts = posts.all() posts = random.sample(posts, k=len(posts))