fsd
This commit is contained in:
parent
0e5d5dd327
commit
42a0286be0
1 changed files with 8 additions and 5 deletions
|
@ -102,6 +102,7 @@ def notifications(v):
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
g.db.commit()
|
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,
|
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,
|
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/%')
|
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())
|
).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(
|
comments = g.db.query(Comment).join(Notification).distinct(Comment.top_comment_id).filter(
|
||||||
Notification.user_id == v.id,
|
Notification.user_id == v.id,
|
||||||
Comment.is_banned == False,
|
Comment.is_banned == False,
|
||||||
|
@ -120,7 +123,7 @@ def notifications(v):
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
comments = comments[:25]
|
comments = comments[:25]
|
||||||
|
|
||||||
print("1: " + str(time.time() - t), flush=True)
|
print("3: " + str(time.time() - t), flush=True)
|
||||||
|
|
||||||
cids = set()
|
cids = set()
|
||||||
listing = []
|
listing = []
|
||||||
|
@ -128,12 +131,12 @@ def notifications(v):
|
||||||
if c.parent_submission:
|
if c.parent_submission:
|
||||||
if not c.replies2:
|
if not c.replies2:
|
||||||
c.replies2 = c.child_comments.filter(or_(Comment.author_id == v.id, Comment.id.in_(all))).all()
|
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):
|
while c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment in comments):
|
||||||
c = c.parent_comment
|
c = c.parent_comment
|
||||||
if not c.replies2:
|
if not c.replies2:
|
||||||
c.replies2 = c.child_comments.filter(or_(Comment.author_id == v.id, Comment.id.in_(all))).all()
|
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)
|
cids.add(c.id)
|
||||||
else:
|
else:
|
||||||
while c.parent_comment:
|
while c.parent_comment:
|
||||||
|
@ -142,13 +145,13 @@ def notifications(v):
|
||||||
|
|
||||||
if c not in listing: listing.append(c)
|
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)
|
comms = get_comments(list(cids), v=v)
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return {"data":[x.json for x in listing]}
|
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",
|
return render_template("notifications.html",
|
||||||
v=v,
|
v=v,
|
||||||
notifications=listing,
|
notifications=listing,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue