From f0111e743413df6d0d40075b35194e9714b2142d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 13 Oct 2021 16:44:59 +0200 Subject: [PATCH] gfdg --- files/routes/front.py | 44 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index bee1202e0..f3d3ac437 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -27,48 +27,44 @@ def notifications(v): next_exists = (len(comments) > 25) comments = comments[:25] elif posts: - notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(100).all() + notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all() - comments = [] + next_exists = (len(notifications) > 100) + notifications = notifications[:100] + + listing = [] for index, x in enumerate(notifications): c = x.comment - if x.read and index > 26: break + if x.read and index > 25: break elif not x.read: c.unread = True x.read = True g.db.add(x) - comments.append(c) + listing.append(c) g.db.commit() - next_exists = (len(comments) > 25) - listing = comments[:25] else: + notifications = v.notifications.join(Notification.comment).filter(Comment.author_id != AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all() - notifications = v.notifications.join(Notification.comment).filter( - Comment.is_banned == False, - Comment.deleted_utc == 0, - Comment.author_id != AUTOJANNY_ACCOUNT, - ).order_by(Notification.id.desc()).offset(50 * (page - 1)).limit(51).all() + next_exists = (len(notifications) > 100) + notifications = notifications[:100] - next_exists = (len(notifications) > 50) - notifications = notifications[:50] - cids = [x.comment_id for x in notifications] - comments = get_comments(cids, v=v, load_parent=True) + listing = [] - i = 0 - for x in notifications: - try: - if not x.read: - comments[i].unread = True - x.read = True - g.db.add(x) - except: continue - i += 1 + for index, x in enumerate(notifications): + c = x.comment + if x.read and index > 25: break + elif not x.read: + x.read = True + g.db.add(x) + listing.append(c.id) g.db.commit() + comments = get_comments(listing, v=v, load_parent=True) + if not posts: listing = [] for c in comments: