From 4e10e05dbb64723f6e723bce3fef70be54ba9b4b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 4 Apr 2022 01:15:57 +0200 Subject: [PATCH] fds --- files/routes/front.py | 47 ++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index 656aeec74..861c6b61c 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -54,36 +54,34 @@ def notifications(v): comments = comments[:25] comments = [x.parent_comm] elif posts: - notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ID).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all() + notifications = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(Notification.user_id == v.id, Comment.author_id == AUTOJANNY_ID).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all() listing = [] - for index, x in enumerate(notifications[:100]): - c = x.comment - if x.read and index > 24: break - elif not x.read: - x.read = True + for index, n. c in enumerate(notifications[:100]): + if n.read and index > 24: break + elif not n.read: + n.read = True c.unread = True - g.db.add(x) - if x.created_utc > 1620391248: c.notif_utc = x.created_utc + g.db.add(n) + if n.created_utc > 1620391248: c.notif_utc = n.created_utc listing.append(c) g.db.commit() next_exists = (len(notifications) > len(listing)) elif reddit: - notifications = v.notifications.join(Notification.comment).filter(Comment.body_html.like('

New rdrama mention: 24: break - elif not x.read: - x.read = True + for index, n, c in enumerate(notifications[:100]): + if n.read and index > 24: break + elif not n.read: + n.read = True c.unread = True - g.db.add(x) - if x.created_utc > 1620391248: c.notif_utc = x.created_utc + g.db.add(n) + if n.created_utc > 1620391248: c.notif_utc = n.created_utc listing.append(c) g.db.commit() @@ -95,20 +93,19 @@ def notifications(v): Notification.user_id == v.id, Comment.author_id != AUTOJANNY_ID, Comment.body_html.notlike('

New rdrama mention: