devrama
This commit is contained in:
parent
42dce924ef
commit
eb1dece08f
1 changed files with 10 additions and 15 deletions
|
@ -9,7 +9,7 @@ defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
|
||||||
@app.post("/clear")
|
@app.post("/clear")
|
||||||
@auth_required
|
@auth_required
|
||||||
def clear(v):
|
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:
|
for n in notifs:
|
||||||
n.read = True
|
n.read = True
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
@ -19,7 +19,7 @@ def clear(v):
|
||||||
@app.get("/unread")
|
@app.get("/unread")
|
||||||
@auth_required
|
@auth_required
|
||||||
def unread(v):
|
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.read == False,
|
||||||
Notification.user_id == v.id,
|
Notification.user_id == v.id,
|
||||||
Comment.is_banned == False,
|
Comment.is_banned == False,
|
||||||
|
@ -54,7 +54,7 @@ def notifications(v):
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
listing = comments[:25]
|
listing = comments[:25]
|
||||||
elif posts:
|
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 = []
|
listing = []
|
||||||
|
|
||||||
|
@ -72,7 +72,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 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 = []
|
listing = []
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ def notifications(v):
|
||||||
|
|
||||||
next_exists = (len(notifications) > len(listing))
|
next_exists = (len(notifications) > len(listing))
|
||||||
else:
|
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.read == False,
|
||||||
Notification.user_id == v.id,
|
Notification.user_id == v.id,
|
||||||
Comment.author_id != AUTOJANNY_ID,
|
Comment.author_id != AUTOJANNY_ID,
|
||||||
|
@ -105,7 +105,7 @@ def notifications(v):
|
||||||
print("1: " + str(time.time()-t))
|
print("1: " + str(time.time()-t))
|
||||||
t = time.time()
|
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,
|
Notification.user_id == v.id,
|
||||||
Comment.is_banned == False,
|
Comment.is_banned == False,
|
||||||
Comment.deleted_utc == 0,
|
Comment.deleted_utc == 0,
|
||||||
|
@ -147,16 +147,11 @@ def notifications(v):
|
||||||
|
|
||||||
for c, n in all:
|
for c, n in all:
|
||||||
if n > 1620391248: c.notif_utc = n
|
if n > 1620391248: c.notif_utc = n
|
||||||
|
|
||||||
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
|
parent = c.parent_comment
|
||||||
if parent.replies2 == None: parent.replies2 = [c]
|
if parent and c.parent_submission:
|
||||||
elif c not in parent.replies2: parent.replies2.append(c)
|
if not parent.replies2: parent.replies2 = [c]
|
||||||
c = parent
|
else: parent.replies2.append(c)
|
||||||
|
|
||||||
if c.replies2 == None: c.replies2 = []
|
|
||||||
|
|
||||||
print("6: " + str(time.time()-t))
|
print("6: " + str(time.time()-t))
|
||||||
t = time.time()
|
t = time.time()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue