diff --git a/files/routes/comments.py b/files/routes/comments.py index 339352e13..0b2fae8dc 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -9,7 +9,7 @@ from files.routes.front import comment_idlist from pusher_push_notifications import PushNotifications from flask import * from files.__main__ import app, limiter -from sqlalchemy.orm import contains_eager + site = environ.get("DOMAIN").strip() @@ -183,7 +183,7 @@ def api_comment(v): Comment.parent_comment_id == parent_comment_id, Comment.parent_submission == parent_submission, CommentAux.body == body - ).options(contains_eager(Comment.comment_aux)).first() + ).first() if existing: return {"error": f"You already made that comment: {existing.permalink}"}, 409 @@ -207,7 +207,7 @@ def api_comment(v): CommentAux.body.op( '<->')(body) < app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"], Comment.created_utc > cutoff - ).options(contains_eager(Comment.comment_aux)).all() + ).all() threshold = app.config["COMMENT_SPAM_COUNT_THRESHOLD"] if v.age >= (60 * 60 * 24 * 7): @@ -671,7 +671,7 @@ def edit_comment(cid, v): CommentAux.body.op( '<->')(body) < app.config["SPAM_SIMILARITY_THRESHOLD"], Comment.created_utc > cutoff - ).options(contains_eager(Comment.comment_aux)).all() + ).all() threshold = app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] if v.age >= (60 * 60 * 24 * 30): diff --git a/files/routes/search.py b/files/routes/search.py index a6301b264..d2c2f13d0 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -3,8 +3,7 @@ import re from sqlalchemy import * from flask import * from files.__main__ import app -import random -from sqlalchemy.orm import contains_eager + query_regex=re.compile("(\w+):(\S+)") valid_params=[ @@ -143,11 +142,6 @@ def searchposts(v): cutoff = 0 posts = posts.filter(Submission.created_utc >= cutoff) - posts=posts.options( - contains_eager(Submission.submission_aux), - contains_eager(Submission.author), - ) - if sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": @@ -245,9 +239,6 @@ def searchcomments(v): cutoff = 0 comments = comments.filter(Comment.created_utc >= cutoff) - comments=comments.options(contains_eager(Comment.comment_aux)) - - if sort == "new": diff --git a/files/routes/users.py b/files/routes/users.py index 6acc04866..21155eefa 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -11,7 +11,6 @@ from files.mail import * from flask import * from files.__main__ import app, limiter from pusher_push_notifications import PushNotifications -from sqlalchemy.orm import contains_eager site = environ.get("DOMAIN").strip() @@ -228,7 +227,7 @@ def message2(v, username): existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id, Comment.sentto == user.id, CommentAux.body == message, - ).options(contains_eager(Comment.comment_aux)).first() + ).first() if existing: return redirect('/notifications?messages=true') text = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', message) @@ -288,7 +287,7 @@ def messagereply(v): existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id, Comment.sentto == user.id, CommentAux.body == message, - ).options(contains_eager(Comment.comment_aux)).first() + ).first() if existing: if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}') else: return redirect(f'/notifications?messages=true#comment-{existing.id}')