diff --git a/files/routes/front.py b/files/routes/front.py index 4bc208463..4a71f1898 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -19,7 +19,7 @@ def clear(v): @app.get("/unread") @auth_required def unread(v): - listing = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter( + listing = g.db.query(Notification, Comment).filter( Notification.read == False, Notification.user_id == v.id, Comment.is_banned == False, @@ -54,7 +54,7 @@ def notifications(v): next_exists = (len(comments) > 25) listing = comments[:25] elif posts: - 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() + notifications = g.db.query(Notification, Comment).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 = [] @@ -72,7 +72,7 @@ def notifications(v): next_exists = (len(notifications) > len(listing)) elif reddit: - notifications = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(Notification.user_id == v.id, Comment.body_html.like('
New rdrama mention: len(listing)) else: - unread = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter( + unread = g.db.query(Notification, Comment).filter( Notification.read == False, Notification.user_id == v.id, Comment.author_id != AUTOJANNY_ID, @@ -102,7 +102,10 @@ def notifications(v): g.db.add(c) g.db.commit() - sq = g.db.query(Comment.id, Notification.created_utc).join(Notification).distinct(Comment.top_comment_id).filter( + print("1: " + str(time.time()-t)) + t = time.time() + + sq = g.db.query(Comment.id, Notification.created_utc).distinct(Comment.top_comment_id).filter( Notification.user_id == v.id, Comment.is_banned == False, Comment.deleted_utc == 0, @@ -110,35 +113,56 @@ def notifications(v): Comment.body_html.notlike('