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) next_exists = (len(comments) > 25)
comments = comments[:25] comments = comments[:25]
elif posts: 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 = [] comments = []
@ -50,10 +50,10 @@ def notifications(v):
Comment.is_banned == False, Comment.is_banned == False,
Comment.deleted_utc == 0, Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ACCOUNT, 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) next_exists = (len(notifications) > 50)
notifications = notifications[:25] notifications = notifications[:50]
cids = [x.comment_id for x in notifications] cids = [x.comment_id for x in notifications]
comments = get_comments(cids, v=v, load_parent=True) comments = get_comments(cids, v=v, load_parent=True)

View File

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

View File

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