remotes/1693045480750635534/spooky-22
Aevann1 2021-09-13 16:44:28 +02:00
parent 28f1fdaee4
commit bc0e608b4f
4 changed files with 6 additions and 23 deletions

View File

@ -369,15 +369,6 @@ class User(Base, Stndrd, Age_times):
return self.notifications.filter(Notification.read == False).join(Notification.comment).filter(
Comment.author_id == AUTOJANNY_ACCOUNT).count()
def notification_messages(self, page=1):
comments = g.db.query(Comment).filter(or_(Comment.author_id==self.id, Comment.sentto==self.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all()
for c in comments:
print(c.child_comments)
return [c[0] for c in comments]
@property
@lazy
def notifications_count(self):

View File

@ -190,4 +190,3 @@ def send_admin(vid, text):
for admin in admins:
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)
cache.delete_memoized(User.notification_messages, admin)

View File

@ -21,17 +21,13 @@ def notifications(v):
modmail = request.args.get('modmail', False)
posts = request.args.get('posts', False)
if modmail and v.admin_level == 6:
comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).all()
firstrange = 100 * (page - 1)
secondrange = firstrange + 101
comments = comments[firstrange:secondrange]
next_exists = (len(comments) > 100)
comments = comments[:100]
comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all()
next_exists = (len(comments) > 25)
comments = comments[:25]
elif messages:
cids = v.notification_messages(page=page)
next_exists = (len(cids) > 25)
cids = cids[:25]
comments = get_comments(cids, v=v)
comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all()
next_exists = (len(comments) > 25)
comments = comments[:25]
elif posts:
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).all()

View File

@ -216,8 +216,6 @@ def message2(v, username):
send_pm(v.id, user, message)
cache.delete_memoized(User.notification_messages, user)
try:
beams_client.publish_to_interests(
interests=[str(user.id)],
@ -270,7 +268,6 @@ def messagereply(v):
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id, user_id=user.id)
g.db.add(notif)
cache.delete_memoized(User.notification_messages, user)
return jsonify({"html": render_template("comments.html",
v=v,