From 91951ed14213a422edaa3cd618216ff816b9e258 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 3 Jul 2022 06:27:48 +0200 Subject: [PATCH] messing with relationships --- files/helpers/get.py | 10 ++++------ files/routes/posts.py | 7 +++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/files/helpers/get.py b/files/helpers/get.py index 55782e701..e2f5e6cdc 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -147,9 +147,8 @@ def get_post(i, v=None, graceful=False, rendered=False): posts = post.options( joinedload(Submission.flags), joinedload(Submission.awards), - joinedload(Submission.author), - joinedload(Submission.options), - joinedload(Submission.options, SubmissionOption.votes) + joinedload(Submission.author).joinedload(User.badges), + joinedload(Submission.options).joinedload(SubmissionOption.votes) ) post=post.one_or_none() @@ -204,9 +203,8 @@ def get_posts(pids, v=None): isouter=True ).options(joinedload(Submission.flags), joinedload(Submission.awards), - joinedload(Submission.author), - joinedload(Submission.options), - joinedload(Submission.options, SubmissionOption.votes) + joinedload(Submission.author).joinedload(User.badges), + joinedload(Submission.options).joinedload(SubmissionOption.votes) ).all() output = [p[0] for p in query] diff --git a/files/routes/posts.py b/files/routes/posts.py index 646d53c23..5053ff3b6 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -171,12 +171,11 @@ def post_id(pid, anything=None, v=None, sub=None): blocked.c.user_id == Comment.author_id, isouter=True ).options( + joinedload(Comment.child_comments), joinedload(Comment.flags), joinedload(Comment.awards), - joinedload(Comment.author), - joinedload(Comment.options), - joinedload(Comment.options, CommentOption.votes), - joinedload(Comment.child_comments) + joinedload(Comment.author).joinedload(User.badges), + joinedload(Comment.options).joinedload(CommentOption.votes) ) output = []