From 47fe4ca887ca33ab71389afc48af76d810ada2b2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 13 Sep 2021 16:28:56 +0200 Subject: [PATCH] fd --- files/classes/user.py | 12 ++++++++---- files/routes/front.py | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index a83d070e2..349d5e594 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -373,11 +373,15 @@ class User(Base, Stndrd, Age_times): def notification_messages(self, page=1): comments = g.db.query(Comment).filter(or_(Comment.author_id==self.id, Comment.sentto==self.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc()).all() - comments = [c.id for c in comments if c.child_comments == []] + comments2 = [] + for c in comments: + if c.child_comments == []: + comments2.append(c) + if len(comments2) == 26: break - firstrange = 100 * (page - 1) - secondrange = firstrange + 101 - return comments[firstrange:secondrange] + firstrange = 25 * (page - 1) + secondrange = firstrange + 26 + return comments2[firstrange:secondrange] @property @lazy diff --git a/files/routes/front.py b/files/routes/front.py index 46d2fd1a4..486bf639f 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -29,8 +29,8 @@ def notifications(v): comments = comments[:100] elif messages: cids = v.notification_messages(page=page) - next_exists = (len(cids) > 100) - cids = cids[:100] + next_exists = (len(cids) > 25) + cids = cids[:25] comments = get_comments(cids, v=v) elif posts: notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).all()