master
Aevann1 2021-10-13 16:44:59 +02:00
parent 848749e09a
commit f0111e7434
1 changed files with 20 additions and 24 deletions

View File

@ -27,48 +27,44 @@ def notifications(v):
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)).limit(100).all()
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all()
comments = []
next_exists = (len(notifications) > 100)
notifications = notifications[:100]
listing = []
for index, x in enumerate(notifications):
c = x.comment
if x.read and index > 26: break
if x.read and index > 25: break
elif not x.read:
c.unread = True
x.read = True
g.db.add(x)
comments.append(c)
listing.append(c)
g.db.commit()
next_exists = (len(comments) > 25)
listing = comments[:25]
else:
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id != AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all()
notifications = v.notifications.join(Notification.comment).filter(
Comment.is_banned == False,
Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ACCOUNT,
).order_by(Notification.id.desc()).offset(50 * (page - 1)).limit(51).all()
next_exists = (len(notifications) > 100)
notifications = notifications[:100]
next_exists = (len(notifications) > 50)
notifications = notifications[:50]
cids = [x.comment_id for x in notifications]
comments = get_comments(cids, v=v, load_parent=True)
listing = []
i = 0
for x in notifications:
try:
if not x.read:
comments[i].unread = True
x.read = True
g.db.add(x)
except: continue
i += 1
for index, x in enumerate(notifications):
c = x.comment
if x.read and index > 25: break
elif not x.read:
x.read = True
g.db.add(x)
listing.append(c.id)
g.db.commit()
comments = get_comments(listing, v=v, load_parent=True)
if not posts:
listing = []
for c in comments: