remotes/1693045480750635534/spooky-22
Aevann1 2022-04-04 01:51:00 +02:00
parent b93af5b09d
commit 798e7e9e55
1 changed files with 8 additions and 5 deletions

View File

@ -102,6 +102,7 @@ def notifications(v):
g.db.add(c)
g.db.commit()
print("1: " + str(time.time() - t), flush=True)
all = set(x[0] for x in g.db.query(Notification.comment_id).join(Comment, Notification.comment_id == Comment.id).filter(Comment.is_banned == False,
Comment.deleted_utc == 0,
@ -109,6 +110,8 @@ def notifications(v):
Comment.body_html.notlike('<html><body><p>New rdrama mention: <a href="https://old.reddit.com/r/%')
).order_by(Comment.top_comment_id.desc()).limit(50 + 50*page).all())
print("2: " + str(time.time() - t), flush=True)
comments = g.db.query(Comment).join(Notification).distinct(Comment.top_comment_id).filter(
Notification.user_id == v.id,
Comment.is_banned == False,
@ -120,7 +123,7 @@ def notifications(v):
next_exists = (len(comments) > 25)
comments = comments[:25]
print("1: " + str(time.time() - t), flush=True)
print("3: " + str(time.time() - t), flush=True)
cids = set()
listing = []
@ -128,12 +131,12 @@ def notifications(v):
if c.parent_submission:
if not c.replies2:
c.replies2 = c.child_comments.filter(or_(Comment.author_id == v.id, Comment.id.in_(all))).all()
cids.update(x.id for x in c.replies2)
cids = cids | set(x.id for x in c.replies2)
while c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment in comments):
c = c.parent_comment
if not c.replies2:
c.replies2 = c.child_comments.filter(or_(Comment.author_id == v.id, Comment.id.in_(all))).all()
cids.update(x.id for x in c.replies2)
cids = cids | set(x.id for x in c.replies2)
cids.add(c.id)
else:
while c.parent_comment:
@ -142,13 +145,13 @@ def notifications(v):
if c not in listing: listing.append(c)
print("2: " + str(time.time() - t), flush=True)
print("4: " + str(time.time() - t), flush=True)
comms = get_comments(list(cids), v=v)
if request.headers.get("Authorization"): return {"data":[x.json for x in listing]}
print("3: " + str(time.time() - t), flush=True)
print("5: " + str(time.time() - t), flush=True)
return render_template("notifications.html",
v=v,
notifications=listing,