forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-09-11 06:11:33 +02:00
parent c2fd01ff4e
commit 79045218df
1 changed files with 20 additions and 21 deletions

View File

@ -22,18 +22,17 @@ def notifications(v):
posts = request.args.get('posts', False) posts = request.args.get('posts', False)
if modmail and v.admin_level == 6: if modmail and v.admin_level == 6:
comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).all() comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).all()
firstrange = 25 * (page - 1) firstrange = 100 * (page - 1)
secondrange = firstrange + 26 comments = comments[:firstrange]
comments = comments[firstrange:secondrange] next_exists = (len(comments) > 100)
next_exists = (len(comments) > 25) comments = comments[:100]
comments = comments[:25]
elif messages: elif messages:
cids = v.notification_messages(page=page) cids = v.notification_messages(page=page)
next_exists = (len(cids) > 25) next_exists = (len(cids) > 100)
cids = cids[:25] cids = cids[:100]
comments = get_comments(cids, v=v) comments = get_comments(cids, v=v)
elif posts: elif posts:
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).all() notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(100 * (page - 1)).all()
comments = [] comments = []
for index, x in enumerate(notifications): for index, x in enumerate(notifications):
@ -51,21 +50,20 @@ def notifications(v):
Comment.is_banned == False, Comment.is_banned == False,
Comment.deleted_utc == 0, Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ACCOUNT, Comment.author_id != AUTOJANNY_ACCOUNT,
).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() ).order_by(Notification.id.desc()).offset(100 * (page - 1)).all()
next_exists = (len(notifications) > 25)
notifications = notifications[:25]
cids = [x.comment_id for x in notifications]
comments = get_comments(cids, v=v, load_parent=True)
i = 0 comments = []
for x in notifications: for index, x in enumerate(notifications):
try: c = x.comment
if not x.read: comments[i].unread = True if x.read and index > 101: break
except: continue elif not x.read:
x.read = True c.unread = True
g.db.add(x) x.read = True
i += 1 g.db.add(x)
comments.append(c)
next_exists = (len(comments) > 100)
listing = comments[:100]
if not posts: if not posts:
listing = [] listing = []
@ -104,6 +102,7 @@ def notifications(v):
render_replies=True, render_replies=True,
is_notification_page=True) is_notification_page=True)
@cache.memoize(timeout=86400) @cache.memoize(timeout=86400)
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', **kwargs): def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', **kwargs):