fds
This commit is contained in:
parent
f157385e3d
commit
d8be3430ab
1 changed files with 32 additions and 44 deletions
|
@ -102,7 +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)
|
print("1: " + 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,
|
||||||
|
@ -115,62 +115,50 @@ def notifications(v):
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
comments = comments[:25]
|
comments = comments[:25]
|
||||||
|
|
||||||
sex = time.time()
|
print("2: " + str(time.time() - t), flush=True)
|
||||||
cids = [x[0] for x in g.db.query(Comment.id).join(Notification).filter(
|
|
||||||
Notification.user_id == v.id,
|
|
||||||
Comment.is_banned == False,
|
|
||||||
Comment.deleted_utc == 0,
|
|
||||||
Comment.author_id != AUTOJANNY_ID,
|
|
||||||
Comment.body_html.notlike('<html><body><p>New rdrama mention: <a href="https://old.reddit.com/r/%')
|
|
||||||
).order_by(Comment.top_comment_id.desc()).all()]
|
|
||||||
print(time.time() - sex)
|
|
||||||
|
|
||||||
sex = time.time()
|
|
||||||
cids = g.db.query(Comment).join(Notification).filter(
|
cids = g.db.query(Comment).join(Notification).filter(
|
||||||
Notification.user_id == v.id,
|
Notification.user_id == v.id,
|
||||||
Comment.is_banned == False,
|
Comment.is_banned == False,
|
||||||
Comment.deleted_utc == 0,
|
Comment.deleted_utc == 0,
|
||||||
Comment.author_id != AUTOJANNY_ID,
|
Comment.author_id != AUTOJANNY_ID,
|
||||||
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()).all()
|
).order_by(Comment.top_comment_id.desc())
|
||||||
print(time.time() - sex)
|
|
||||||
|
|
||||||
|
|
||||||
# # print("3: " + str(time.time() - t), flush=True)
|
print("3: " + str(time.time() - t), flush=True)
|
||||||
|
|
||||||
# listing = []
|
listing = []
|
||||||
# for c in comments:
|
for c in comments:
|
||||||
# if c.parent_submission:
|
if c.parent_submission:
|
||||||
# if c.replies2 == None:
|
if c.replies2 == None:
|
||||||
# c.replies2 = c.child_comments.filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).all()
|
c.replies2 = c.child_comments.filter(Comment.author_id == v.id).all() + cids.filter(Comment.parent_comment_id == c.id).all()
|
||||||
# for x in c.replies2:
|
for x in c.replies2:
|
||||||
# if x.replies2 == None: x.replies2 = []
|
if x.replies2 == None: x.replies2 = []
|
||||||
# while c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids):
|
while c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids):
|
||||||
# c = c.parent_comment
|
c = c.parent_comment
|
||||||
# if c.replies2 == None:
|
if c.replies2 == None:
|
||||||
# c.replies2 = c.child_comments.filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).all()
|
c.replies2 = c.child_comments.filter(Comment.author_id == v.id).all() + cids.filter(Comment.parent_comment_id == c.id).all()
|
||||||
# for x in c.replies2:
|
for x in c.replies2:
|
||||||
# if x.replies2 == None: x.replies2 = []
|
if x.replies2 == None: x.replies2 = []
|
||||||
# else:
|
else:
|
||||||
# while c.parent_comment:
|
while c.parent_comment:
|
||||||
# c = c.parent_comment
|
c = c.parent_comment
|
||||||
# c.replies2 = g.db.query(Comment).filter_by(parent_comment_id=c.id).order_by(Comment.id).all()
|
c.replies2 = g.db.query(Comment).filter_by(parent_comment_id=c.id).order_by(Comment.id).all()
|
||||||
|
|
||||||
# if c not in listing: listing.append(c)
|
if c not in listing: listing.append(c)
|
||||||
|
|
||||||
# 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("5: " + 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,
|
||||||
# next_exists=next_exists,
|
next_exists=next_exists,
|
||||||
# page=page,
|
page=page,
|
||||||
# standalone=True,
|
standalone=True,
|
||||||
# render_replies=True
|
render_replies=True
|
||||||
# )
|
)
|
||||||
|
|
||||||
return 'fuq'
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue