diff --git a/files/classes/user.py b/files/classes/user.py index 4a9d159f7..18a5e0c1d 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -369,15 +369,6 @@ 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_messages(self, page=1): - 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(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all() - - for c in comments: - print(c.child_comments) - - return [c[0] for c in comments] - @property @lazy def notifications_count(self): diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 3fff33cf5..3ef068440 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -190,4 +190,3 @@ def send_admin(vid, text): for admin in admins: notif = Notification(comment_id=new_comment.id, user_id=admin.id) g.db.add(notif) - cache.delete_memoized(User.notification_messages, admin) diff --git a/files/routes/front.py b/files/routes/front.py index 486bf639f..e343f99a5 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -21,17 +21,13 @@ def notifications(v): modmail = request.args.get('modmail', False) posts = request.args.get('posts', False) if modmail and v.admin_level == 6: - comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).all() - firstrange = 100 * (page - 1) - secondrange = firstrange + 101 - comments = comments[firstrange:secondrange] - next_exists = (len(comments) > 100) - comments = comments[:100] + comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all() + next_exists = (len(comments) > 25) + comments = comments[:25] elif messages: - cids = v.notification_messages(page=page) - next_exists = (len(cids) > 25) - cids = cids[:25] - comments = get_comments(cids, v=v) + comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all() + 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)).all() diff --git a/files/routes/users.py b/files/routes/users.py index d1a549cb1..6a8f88825 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -216,8 +216,6 @@ def message2(v, username): send_pm(v.id, user, message) - cache.delete_memoized(User.notification_messages, user) - try: beams_client.publish_to_interests( interests=[str(user.id)], @@ -270,7 +268,6 @@ def messagereply(v): g.db.add(new_aux) notif = Notification(comment_id=new_comment.id, user_id=user.id) g.db.add(notif) - cache.delete_memoized(User.notification_messages, user) return jsonify({"html": render_template("comments.html", v=v,