From 79178696e00bd8669cb74655bcecfd79a48521ea Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 5 Nov 2021 19:55:23 +0200 Subject: [PATCH] grugposting --- files/classes/user.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index fbe000d9cc..5487c525f2 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -340,16 +340,19 @@ class User(Base): @property @lazy - def post_notifications_count(self): - return self.notifications.filter(Notification.read == False).join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).count() + def unread_notifications(self): + return g.db.query(Notification.id).options(lazyload('*')).filter(Notification.user_id == self.id, Notification.read == False) @property @lazy def notifications_count(self): + return self.unread_notifications.count() + + @property + @lazy + def post_notifications_count(self): + return self.unread_notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).count() - return self.notifications.join(Notification.comment).filter(Notification.read == False, - Comment.is_banned == False, - Comment.deleted_utc == 0).count() @property @lazy