diff --git a/files/classes/user.py b/files/classes/user.py index 3888f357a..1bbd67bb3 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -353,19 +353,9 @@ class User(Base, Stndrd, Age_times): return self.notifications.filter(Notification.read == False).join(Notification.comment).filter( Comment.author_id == AUTOJANNY_ACCOUNT).count() - def notification_modmail(self, page=1): - - comments = g.db.query(Comment).filter(Comment.sentto==0).filter(Comment.parent_submission == None).order_by(Comment.created_utc.desc()).all() - - comments = [c.id for c in comments if c.child_comments == []] - - firstrange = 25 * (page - 1) - secondrange = firstrange + 26 - return comments[firstrange:secondrange] - @cache.memoize(timeout=86400) def notification_messages(self, page=1): - comments = g.db.query(Comment).filter(or_(Comment.author_id==self.id, Comment.sentto==self.id)).filter(Comment.parent_submission == None).order_by(Comment.created_utc.desc()).limit(100).all() + 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()).limit(100).all() comments = [c.id for c in comments if c.child_comments == []] diff --git a/files/routes/front.py b/files/routes/front.py index 8865882fb..3ec111ccd 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -21,10 +21,12 @@ def notifications(v): modmail = request.args.get('modmail', False) posts = request.args.get('posts', False) if modmail and v.admin_level == 6: - cids = v.notification_modmail(page=page) - next_exists = (len(cids) == 26) - cids = cids[:25] - comments = get_comments(cids, v=v) + comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).all() + firstrange = 25 * (page - 1) + secondrange = firstrange + 26 + comments = comments[firstrange:secondrange] + next_exists = (len(comments) == 26) + comments = comments[:25] elif messages: cids = v.notification_messages(page=page) next_exists = (len(cids) == 26)