remotes/1693045480750635534/spooky-22
Aevann1 2021-09-23 17:29:36 +02:00
parent fa7cb304e3
commit f92bbc7320
3 changed files with 60 additions and 60 deletions

View File

@ -27,7 +27,7 @@ def notifications(v):
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)).limit(26).all()
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(100).all()
comments = []
@ -50,10 +50,10 @@ def notifications(v):
Comment.is_banned == False,
Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ACCOUNT,
).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all()
).order_by(Notification.id.desc()).offset(50 * (page - 1)).limit(51).all()
next_exists = (len(notifications) > 25)
notifications = notifications[:25]
next_exists = (len(notifications) > 50)
notifications = notifications[:50]
cids = [x.comment_id for x in notifications]
comments = get_comments(cids, v=v, load_parent=True)

View File

@ -203,73 +203,73 @@ def searchposts(v):
domain_obj=domain_obj
)
@app.get("/search/comments")
@auth_desired
def searchcomments(v):
# @app.get("/search/comments")
# @auth_desired
# def searchcomments(v):
query = request.values.get("q", '').strip()
# query = request.values.get("q", '').strip()
try: page = max(1, int(request.values.get("page", 1)))
except: page = 1
# try: page = max(1, int(request.values.get("page", 1)))
# except: page = 1
sort = request.values.get("sort", "top").lower()
t = request.values.get('t', 'all').lower()
# sort = request.values.get("sort", "top").lower()
# t = request.values.get('t', 'all').lower()
criteria=searchparse(query)
# criteria=searchparse(query)
comments = g.db.query(Comment).filter(Comment.parent_submission != None).join(Comment.comment_aux)
# comments = g.db.query(Comment).filter(Comment.parent_submission != None).join(Comment.comment_aux)
if 'q' in criteria:
words=criteria['q'].split()
words=[CommentAux.body.ilike('%'+x+'%') for x in words]
words=tuple(words)
comments=comments.filter(*words)
# if 'q' in criteria:
# words=criteria['q'].split()
# words=[CommentAux.body.ilike('%'+x+'%') for x in words]
# words=tuple(words)
# comments=comments.filter(*words)
if not(v and v.admin_level >= 3):
comments = comments.filter(
Comment.deleted_utc == 0,
Comment.is_banned == False)
# if not(v and v.admin_level >= 3):
# comments = comments.filter(
# Comment.deleted_utc == 0,
# Comment.is_banned == False)
if t:
now = int(time.time())
if t == 'hour':
cutoff = now - 3600
elif t == 'day':
cutoff = now - 86400
elif t == 'week':
cutoff = now - 604800
elif t == 'month':
cutoff = now - 2592000
elif t == 'year':
cutoff = now - 31536000
else:
cutoff = 0
comments = comments.filter(Comment.created_utc >= cutoff)
# if t:
# now = int(time.time())
# if t == 'hour':
# cutoff = now - 3600
# elif t == 'day':
# cutoff = now - 86400
# elif t == 'week':
# cutoff = now - 604800
# elif t == 'month':
# cutoff = now - 2592000
# elif t == 'year':
# cutoff = now - 31536000
# else:
# cutoff = 0
# comments = comments.filter(Comment.created_utc >= cutoff)
comments=comments.options(contains_eager(Comment.comment_aux))
# comments=comments.options(contains_eager(Comment.comment_aux))
if sort == "new":
comments = comments.order_by(Comment.created_utc.desc()).all()
elif sort == "old":
comments = comments.order_by(Comment.created_utc.asc()).all()
elif sort == "controversial":
comments = sorted(comments.all(), key=lambda x: x.score_disputed, reverse=True)
elif sort == "top":
comments = sorted(comments.all(), key=lambda x: x.score, reverse=True)
elif sort == "bottom":
comments = sorted(comments.all(), key=lambda x: x.score)
# if sort == "new":
# comments = comments.order_by(Comment.created_utc.desc()).all()
# elif sort == "old":
# comments = comments.order_by(Comment.created_utc.asc()).all()
# elif sort == "controversial":
# comments = sorted(comments.all(), key=lambda x: x.score_disputed, reverse=True)
# elif sort == "top":
# comments = sorted(comments.all(), key=lambda x: x.score, reverse=True)
# elif sort == "bottom":
# comments = sorted(comments.all(), key=lambda x: x.score)
total = len(list(comments))
firstrange = 25 * (page - 1)
secondrange = firstrange+26
comments = comments[firstrange:secondrange]
ids = [x.id for x in comments]
# total = len(list(comments))
# firstrange = 25 * (page - 1)
# secondrange = firstrange+26
# comments = comments[firstrange:secondrange]
# ids = [x.id for x in comments]
@ -278,13 +278,13 @@ def searchcomments(v):
next_exists = (len(ids) > 25)
ids = ids[:25]
# next_exists = (len(ids) > 25)
# ids = ids[:25]
comments = get_comments(ids, v=v)
# comments = get_comments(ids, v=v)
if request.headers.get("Authorization"): return [x.json for x in comments]
else: return render_template("search_comments.html", v=v, query=query, total=total, page=page, comments=comments, sort=sort, t=t, next_exists=next_exists)
# if request.headers.get("Authorization"): return [x.json for x in comments]
# else: return render_template("search_comments.html", v=v, query=query, total=total, page=page, comments=comments, sort=sort, t=t, next_exists=next_exists)
@app.get("/search/users")

View File

@ -1998,7 +1998,7 @@ const char *quotes[] =
"Fuck off we're full",
"NPC lol",
"Lock her up",
"libtards smh"
"libtards smh",
"mayocide isn't funny guys"
};