From f92bbc7320c3c653d3b608e1a3439dbb31432567 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 23 Sep 2021 17:29:36 +0200 Subject: [PATCH] fds --- files/routes/front.py | 8 +-- files/routes/search.py | 110 ++++++++++++++++++++--------------------- snappy.txt | 2 +- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index 6ec6501a7..ce634503e 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -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) diff --git a/files/routes/search.py b/files/routes/search.py index 6b1fcffd8..505d0606d 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -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") diff --git a/snappy.txt b/snappy.txt index afa3f3318..e2012a02c 100644 --- a/snappy.txt +++ b/snappy.txt @@ -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" };