forked from rDrama/rDrama
dfs
parent
5fc33e2039
commit
957e42ecbb
|
@ -41,7 +41,7 @@ def notifications(v):
|
||||||
notifs.append(x)
|
notifs.append(x)
|
||||||
comments.append(c)
|
comments.append(c)
|
||||||
|
|
||||||
g.db.add(notifs)
|
g.db.add_all(notifs)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
|
@ -59,6 +59,7 @@ def notifications(v):
|
||||||
cids = [x.comment_id for x in notifications]
|
cids = [x.comment_id for x in notifications]
|
||||||
comments = get_comments(cids, v=v, load_parent=True)
|
comments = get_comments(cids, v=v, load_parent=True)
|
||||||
|
|
||||||
|
t = time.time()
|
||||||
i = 0
|
i = 0
|
||||||
notifs = []
|
notifs = []
|
||||||
for x in notifications:
|
for x in notifications:
|
||||||
|
@ -70,9 +71,112 @@ def notifications(v):
|
||||||
except: continue
|
except: continue
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
g.db.add(notifs)
|
g.db.add_all(notifs)
|
||||||
|
g.db.commit()
|
||||||
|
print(time.time() - t)
|
||||||
|
|
||||||
|
if not posts:
|
||||||
|
listing = []
|
||||||
|
for c in comments:
|
||||||
|
c._is_blocked = False
|
||||||
|
c._is_blocking = False
|
||||||
|
if c.parent_submission and c.parent_comment and c.parent_comment.author_id == v.id:
|
||||||
|
c.replies = []
|
||||||
|
while c.parent_comment and c.parent_comment.author_id == v.id:
|
||||||
|
parent = c.parent_comment
|
||||||
|
if c not in parent.replies2:
|
||||||
|
parent.replies2 = parent.replies2 + [c]
|
||||||
|
parent.replies = parent.replies2
|
||||||
|
c = parent
|
||||||
|
if c not in listing:
|
||||||
|
listing.append(c)
|
||||||
|
c.replies = c.replies2
|
||||||
|
elif c.parent_submission:
|
||||||
|
c.replies = []
|
||||||
|
if c not in listing:
|
||||||
|
listing.append(c)
|
||||||
|
else:
|
||||||
|
if c.parent_comment:
|
||||||
|
while c.level > 1:
|
||||||
|
c = c.parent_comment
|
||||||
|
|
||||||
|
if c not in listing:
|
||||||
|
listing.append(c)
|
||||||
|
|
||||||
|
|
||||||
|
return render_template("notifications.html",
|
||||||
|
v=v,
|
||||||
|
notifications=listing,
|
||||||
|
next_exists=next_exists,
|
||||||
|
page=page,
|
||||||
|
standalone=True,
|
||||||
|
render_replies=True,
|
||||||
|
is_notification_page=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/notifications2")
|
||||||
|
@auth_required
|
||||||
|
def notifications2(v):
|
||||||
|
try: page = int(request.args.get('page', 1))
|
||||||
|
except: page = 1
|
||||||
|
messages = request.args.get('messages', False)
|
||||||
|
modmail = request.args.get('modmail', False)
|
||||||
|
posts = request.args.get('posts', False)
|
||||||
|
if modmail and v.admin_level == 6:
|
||||||
|
comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all()
|
||||||
|
next_exists = (len(comments) > 25)
|
||||||
|
comments = comments[:25]
|
||||||
|
elif messages:
|
||||||
|
comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all()
|
||||||
|
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(26).all()
|
||||||
|
|
||||||
|
comments = []
|
||||||
|
notifs = []
|
||||||
|
|
||||||
|
for index, x in enumerate(notifications):
|
||||||
|
c = x.comment
|
||||||
|
if x.read and index > 26: break
|
||||||
|
elif not x.read:
|
||||||
|
c.unread = True
|
||||||
|
x.read = True
|
||||||
|
notifs.append(x)
|
||||||
|
comments.append(c)
|
||||||
|
|
||||||
|
g.db.add_all(notifs)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
|
next_exists = (len(comments) > 25)
|
||||||
|
listing = comments[:25]
|
||||||
|
else:
|
||||||
|
|
||||||
|
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(25 * (page - 1)).limit(26).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)
|
||||||
|
|
||||||
|
t = time.time()
|
||||||
|
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
|
||||||
|
|
||||||
|
g.db.commit()
|
||||||
|
print(time.time() - t)
|
||||||
|
|
||||||
if not posts:
|
if not posts:
|
||||||
listing = []
|
listing = []
|
||||||
for c in comments:
|
for c in comments:
|
||||||
|
|
Loading…
Reference in New Issue