remotes/1693045480750635534/spooky-22
Aevann1 2022-04-04 20:36:41 +02:00
parent 16316ec88f
commit 5ff7d64c84
1 changed files with 10 additions and 15 deletions

View File

@ -9,7 +9,7 @@ defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
@app.post("/clear")
@auth_required
def clear(v):
notifs = g.db.query(Notification).join(Comment, Notification.comment_id == Comment.id).filter(Notification.read == False, Notification.user_id == v.id).all()
notifs = g.db.query(Notification).join(Comment).filter(Notification.read == False, Notification.user_id == v.id).all()
for n in notifs:
n.read = True
g.db.add(n)
@ -19,7 +19,7 @@ def clear(v):
@app.get("/unread")
@auth_required
def unread(v):
listing = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(
listing = g.db.query(Notification, Comment).join(Comment).filter(
Notification.read == False,
Notification.user_id == v.id,
Comment.is_banned == False,
@ -54,7 +54,7 @@ def notifications(v):
next_exists = (len(comments) > 25)
listing = comments[:25]
elif posts:
notifications = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(Notification.user_id == v.id, Comment.author_id == AUTOJANNY_ID).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all()
notifications = g.db.query(Notification, Comment).join(Comment).filter(Notification.user_id == v.id, Comment.author_id == AUTOJANNY_ID).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all()
listing = []
@ -72,7 +72,7 @@ def notifications(v):
next_exists = (len(notifications) > len(listing))
elif reddit:
notifications = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(Notification.user_id == v.id, Comment.body_html.like('<html><body><p>New rdrama mention: <a href="https://old.reddit.com/r/%')).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all()
notifications = g.db.query(Notification, Comment).join(Comment).filter(Notification.user_id == v.id, Comment.body_html.like('<html><body><p>New rdrama mention: <a href="https://old.reddit.com/r/%')).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all()
listing = []
@ -90,7 +90,7 @@ def notifications(v):
next_exists = (len(notifications) > len(listing))
else:
unread = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(
unread = g.db.query(Notification, Comment).join(Comment).filter(
Notification.read == False,
Notification.user_id == v.id,
Comment.author_id != AUTOJANNY_ID,
@ -105,7 +105,7 @@ def notifications(v):
print("1: " + str(time.time()-t))
t = time.time()
sq = g.db.query(Comment.id, Notification.created_utc).join(Notification, Notification.comment_id == Comment.id).distinct(Comment.top_comment_id).filter(
sq = g.db.query(Comment.id, Notification.created_utc).join(Notification).distinct(Comment.top_comment_id).filter(
Notification.user_id == v.id,
Comment.is_banned == False,
Comment.deleted_utc == 0,
@ -147,16 +147,11 @@ def notifications(v):
for c, n in all:
if n > 1620391248: c.notif_utc = n
parent = c.parent_comment
if parent and c.parent_submission:
if not parent.replies2: parent.replies2 = [c]
else: parent.replies2.append(c)
if c.parent_submission:
if c.replies2 == None: c.replies2 = []
while c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment in all):
parent = c.parent_comment
if parent.replies2 == None: parent.replies2 = [c]
elif c not in parent.replies2: parent.replies2.append(c)
c = parent
if c.replies2 == None: c.replies2 = []
print("6: " + str(time.time()-t))
t = time.time()