From e1ed46fa36f117b7f1b3d3c5fa4815a74c5cd148 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 1 Dec 2022 00:29:13 +0200 Subject: [PATCH] rework reddit notifs - testing on pcm lol --- files/classes/user.py | 7 ++++--- files/helpers/offsitementions.py | 22 ++++++---------------- files/routes/notifications.py | 24 ++++++------------------ 3 files changed, 16 insertions(+), 37 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index db3b652d2..cd552f416 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -129,6 +129,7 @@ class User(Base): total_lottery_winnings = Column(Integer, default=0) last_viewed_post_notifs = Column(Integer, default=0) last_viewed_log_notifs = Column(Integer, default=0) + last_viewed_reddit_notifs = Column(Integer, default=0) pronouns = Column(String, default='they/them') bite = Column(Integer) earlylife = Column(Integer) @@ -701,9 +702,9 @@ class User(Base): @property @lazy def reddit_notifications_count(self): - if not self.can_view_offsitementions: return 0 - return g.db.query(Notification).join(Comment).filter( - Notification.user_id == self.id, Notification.read == False, + if not self.can_view_offsitementions or self.id == AEVANN_ID: return 0 + return g.db.query(Comment).filter( + Comment.created_utc > self.last_viewed_reddit_notifs, Comment.is_banned == False, Comment.deleted_utc == 0, Comment.body_html.like('%

New site mention% PAGE_SIZE - for index, x in enumerate(notifications[:100]): - n, c = x - if n.read and index > 24: break - elif not n.read: - n.read = True - c.unread = True - g.db.add(n) - if n.created_utc > 1620391248: c.notif_utc = n.created_utc - listing.append(c) - - next_exists = (len(notifications) > len(listing)) - - g.db.commit() + v.last_viewed_reddit_notifs = int(time.time()) + g.db.add(v) if v.client: return {"data":[x.json(g.db) for x in listing]} @@ -271,7 +260,6 @@ def notifications(v:User): Notification.user_id == v.id, Comment.is_banned == False, Comment.deleted_utc == 0, - Comment.body_html.notlike('%

New site mention%