master
Aevann1 2022-04-16 01:19:27 +02:00
parent ff32a6bee3
commit 6a8eff8393
2 changed files with 5 additions and 5 deletions

View File

@ -437,7 +437,7 @@ class User(Base):
@property @property
@lazy @lazy
def reddit_notifications_count(self): def reddit_notifications_count(self):
return g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.is_banned == False, Comment.deleted_utc == 0, Comment.body_html.like('<html><body><p>New site mention: <a href="https://old.reddit.com/r/%')).count() return g.db.query(Notification.user_id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.is_banned == False, Comment.deleted_utc == 0, Comment.body_html.like('$<p>New site mention: <a href="https://old.reddit.com/r/%')).count()
@property @property
@lazy @lazy

View File

@ -75,7 +75,7 @@ def notifications(v):
next_exists = (len(notifications) > len(listing)) next_exists = (len(notifications) > len(listing))
elif reddit: 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 site 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('%<p>New site mention: <a href="https://old.reddit.com/r/%')).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(101).all()
listing = [] listing = []
@ -96,7 +96,7 @@ def notifications(v):
comments = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter( comments = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(
Notification.user_id == v.id, Notification.user_id == v.id,
Comment.author_id != AUTOJANNY_ID, Comment.author_id != AUTOJANNY_ID,
Comment.body_html.notlike('<html><body><p>New site mention: <a href="https://old.reddit.com/r/%') Comment.body_html.notlike('%<p>New site mention: <a href="https://old.reddit.com/r/%')
).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(100).all() ).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(100).all()
for n, c in comments: for n, c in comments:
@ -113,7 +113,7 @@ def notifications(v):
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 site mention: <a href="https://old.reddit.com/r/%') Comment.body_html.notlike('%<p>New site mention: <a href="https://old.reddit.com/r/%')
).order_by(Comment.top_comment_id.desc(), Notification.created_utc.desc()).subquery() ).order_by(Comment.top_comment_id.desc(), Notification.created_utc.desc()).subquery()
if v and (v.shadowbanned or v.admin_level > 2): if v and (v.shadowbanned or v.admin_level > 2):
@ -129,7 +129,7 @@ def notifications(v):
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 site mention: <a href="https://old.reddit.com/r/%') Comment.body_html.notlike('%<p>New site mention: <a href="https://old.reddit.com/r/%')
).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(500).all()] ).order_by(Notification.created_utc.desc()).offset(25 * (page - 1)).limit(500).all()]
comms = get_comments(cids, v=v) comms = get_comments(cids, v=v)