From 672e28b697938bb143833ea98d9f322d87b34c16 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 26 Feb 2023 00:21:59 +0200 Subject: [PATCH 1/4] try to fix repeated notifs --- files/routes/notifications.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 67f8de90b..7f632d534 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -322,7 +322,7 @@ def notifications(v:User): for x in c.replies2: if x.replies2 == None: x.replies2 = [] count = 0 - while count < 50 and c.parent_comment and (count == 0 or c.parent_comment.author_id == v.id or c.parent_comment.id in cids): + while count < 50 and c.parent_comment and ((count == 0 and c.parent_comment.id not in cids) or c.parent_comment.author_id == v.id or c.parent_comment.id in cids): count += 1 c = c.parent_comment if c.replies2 == None: From 691a025db8947058ccb86936285ff105111a3af6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 26 Feb 2023 00:45:09 +0200 Subject: [PATCH 2/4] same as last commit --- files/routes/notifications.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 7f632d534..6b98ada52 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -307,7 +307,7 @@ def notifications(v:User): cids = [x[0].id for x in comments] listing = [] - total = [] + total = [x[0] for x in comments] for c, n in comments: if n.created_utc > 1620391248: c.notif_utc = n.created_utc if not n.read: @@ -321,10 +321,10 @@ def notifications(v:User): total.extend(c.replies2) for x in c.replies2: if x.replies2 == None: x.replies2 = [] - count = 0 - while count < 50 and c.parent_comment and ((count == 0 and c.parent_comment.id not in cids) or c.parent_comment.author_id == v.id or c.parent_comment.id in cids): - count += 1 + + def process(c): c = c.parent_comment + total.append(c) if c.replies2 == None: c.replies2 = g.db.query(Comment).filter_by(parent_comment_id=c.id).filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).order_by(Comment.id.desc()).all() total.extend(c.replies2) @@ -332,11 +332,19 @@ def notifications(v:User): if x.replies2 == None: x.replies2 = g.db.query(Comment).filter_by(parent_comment_id=x.id).filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).order_by(Comment.id.desc()).all() total.extend(x.replies2) + + count = 0 + while count < 50 and c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids): + count += 1 + process(c) + + if count == 0 and c.parent_comment and c.parent_comment not in total: + process(c) + else: while 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() - total.extend(c.replies2) if c not in listing: listing.append(c) From 1623ec93c7441fa3b2dc44dfc60c4204ebe7c61f Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 26 Feb 2023 00:47:50 +0200 Subject: [PATCH 3/4] revert all notification commits made today --- files/routes/notifications.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 6b98ada52..fff73539d 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -307,7 +307,7 @@ def notifications(v:User): cids = [x[0].id for x in comments] listing = [] - total = [x[0] for x in comments] + total = [] for c, n in comments: if n.created_utc > 1620391248: c.notif_utc = n.created_utc if not n.read: @@ -321,10 +321,10 @@ def notifications(v:User): total.extend(c.replies2) for x in c.replies2: if x.replies2 == None: x.replies2 = [] - - def process(c): + count = 0 + while count < 50 and c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids): + count += 1 c = c.parent_comment - total.append(c) if c.replies2 == None: c.replies2 = g.db.query(Comment).filter_by(parent_comment_id=c.id).filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).order_by(Comment.id.desc()).all() total.extend(c.replies2) @@ -332,19 +332,11 @@ def notifications(v:User): if x.replies2 == None: x.replies2 = g.db.query(Comment).filter_by(parent_comment_id=x.id).filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).order_by(Comment.id.desc()).all() total.extend(x.replies2) - - count = 0 - while count < 50 and c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids): - count += 1 - process(c) - - if count == 0 and c.parent_comment and c.parent_comment not in total: - process(c) - else: while 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() + total.extend(c.replies2) if c not in listing: listing.append(c) From c0f9229b4d518ba2ffd3940f9603b1da42915865 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 26 Feb 2023 01:41:17 +0200 Subject: [PATCH 4/4] minor changes in notifications --- files/routes/notifications.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/routes/notifications.py b/files/routes/notifications.py index fff73539d..a2827ddbb 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -307,7 +307,7 @@ def notifications(v:User): cids = [x[0].id for x in comments] listing = [] - total = [] + total = [x[0] for x in comments] for c, n in comments: if n.created_utc > 1620391248: c.notif_utc = n.created_utc if not n.read: @@ -321,6 +321,7 @@ def notifications(v:User): total.extend(c.replies2) for x in c.replies2: if x.replies2 == None: x.replies2 = [] + count = 0 while count < 50 and c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment.id in cids): count += 1 @@ -336,7 +337,6 @@ def notifications(v:User): while 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() - total.extend(c.replies2) if c not in listing: listing.append(c)