remotes/1693045480750635534/spooky-22
Aevann1 2021-09-01 18:26:02 +02:00
parent c6f54cd1b4
commit bdd5fa0a99
2 changed files with 7 additions and 15 deletions

View File

@ -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 == []]

View File

@ -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)