forked from rDrama/rDrama
1
0
Fork 0

order modmail notifs by recency of last message

master
Aevann 2024-02-01 18:14:51 +02:00
parent 40c6c647c6
commit a2774d5285
1 changed files with 3 additions and 4 deletions

View File

@ -138,10 +138,9 @@ def notifications_messages(v):
def notifications_modmail(v):
page = get_page()
comments = g.db.query(Comment).filter_by(
sentto=MODMAIL_ID,
level=1,
)
sq = g.db.query(Comment.top_comment_id, Comment.created_utc).distinct(Comment.top_comment_id).filter_by(sentto=MODMAIL_ID, level=2).order_by(Comment.top_comment_id, Comment.created_utc.desc()).subquery()
comments = g.db.query(Comment).filter(Comment.id == sq.c.top_comment_id).order_by(sq.c.created_utc.desc())
total = comments.count()
listing = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all()