fds
This commit is contained in:
parent
5a43018029
commit
ebe0117548
1 changed files with 22 additions and 25 deletions
|
@ -54,36 +54,34 @@ def notifications(v):
|
|||
comments = comments[:25]
|
||||
comments = [x.parent_comm]
|
||||
elif posts:
|
||||
notifications = v.notifications.join(Notification.comment).filter(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, 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()
|
||||
|
||||
listing = []
|
||||
|
||||
for index, x in enumerate(notifications[:100]):
|
||||
c = x.comment
|
||||
if x.read and index > 24: break
|
||||
elif not x.read:
|
||||
x.read = True
|
||||
for index, n. c in enumerate(notifications[:100]):
|
||||
if n.read and index > 24: break
|
||||
elif not n.read:
|
||||
n.read = True
|
||||
c.unread = True
|
||||
g.db.add(x)
|
||||
if x.created_utc > 1620391248: c.notif_utc = x.created_utc
|
||||
g.db.add(n)
|
||||
if n.created_utc > 1620391248: c.notif_utc = n.created_utc
|
||||
listing.append(c)
|
||||
|
||||
g.db.commit()
|
||||
|
||||
next_exists = (len(notifications) > len(listing))
|
||||
elif reddit:
|
||||
notifications = v.notifications.join(Notification.comment).filter(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, 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()
|
||||
|
||||
listing = []
|
||||
|
||||
for index, x in enumerate(notifications[:100]):
|
||||
c = x.comment
|
||||
if x.read and index > 24: break
|
||||
elif not x.read:
|
||||
x.read = True
|
||||
for index, n, c in enumerate(notifications[:100]):
|
||||
if n.read and index > 24: break
|
||||
elif not n.read:
|
||||
n.read = True
|
||||
c.unread = True
|
||||
g.db.add(x)
|
||||
if x.created_utc > 1620391248: c.notif_utc = x.created_utc
|
||||
g.db.add(n)
|
||||
if n.created_utc > 1620391248: c.notif_utc = n.created_utc
|
||||
listing.append(c)
|
||||
|
||||
g.db.commit()
|
||||
|
@ -95,20 +93,19 @@ def notifications(v):
|
|||
Notification.user_id == v.id,
|
||||
Comment.author_id != AUTOJANNY_ID,
|
||||
Comment.body_html.notlike('<html><body><p>New rdrama mention: <a href="https://old.reddit.com/r/%')
|
||||
)
|
||||
for x in unread:
|
||||
x[0].read = True
|
||||
x[1].unread = True
|
||||
g.db.add(x[0])
|
||||
)
|
||||
for n, c in unread:
|
||||
n.read = True
|
||||
c.unread = True
|
||||
g.db.add(c)
|
||||
g.db.commit()
|
||||
|
||||
|
||||
all = set([x.comment_id for x in v.notifications.join(Notification.comment).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.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()).offset(50 * (page - 1)).limit(100).all()])
|
||||
).order_by(Comment.top_comment_id.desc()).offset(50 * (page - 1)).limit(100).all())
|
||||
|
||||
comments = g.db.query(Comment).join(Notification).distinct(Comment.top_comment_id).filter(
|
||||
Notification.user_id == v.id,
|
||||
|
@ -131,7 +128,7 @@ def notifications(v):
|
|||
while c.parent_comment and (c.parent_comment.author_id == v.id or c.parent_comment in comments):
|
||||
c = c.parent_comment
|
||||
c.replies2 = [x for x in c.child_comments if c.author_id == v.id or x.id in 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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue