From 5cccaf43f70dfb5e8c9356b4f2d8321fe4f5500b Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 17 Dec 2023 15:15:08 +0300 Subject: [PATCH] following-fix-3 --- resolvers/follower.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/resolvers/follower.py b/resolvers/follower.py index 382cefe5..bb5aebb1 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -95,21 +95,18 @@ async def get_my_followed(_, info): author = session.query(Author).filter(Author.user == user_id).first() if author: authors_query = ( - select(Author) - .join(AuthorFollower, AuthorFollower.author == Author.id) - .filter(AuthorFollower.follower == author.id) + select(Author).join(AuthorFollower).filter(AuthorFollower.follower == author.id).from_(Author) ) - topics_query = select(Topic).join(TopicFollower).filter(TopicFollower.follower == author.id) + topics_query = select(Topic).join(TopicFollower).filter(TopicFollower.follower == author.id).from_(Author) + communities_query = ( - select(Community) - .join(CommunityAuthor, CommunityAuthor.author == Author.id) - .filter(CommunityAuthor.author == author.id) + select(Community).join(CommunityAuthor).filter(CommunityAuthor.author == author.id).from_(Author) ) - topics = [t for [t] in session.execute(topics_query)] - authors = [a for [a] in session.execute(authors_query)] - communities = [c for [c] in session.execute(communities_query)] + topics = session.execute(topics_query).scalars().all() + authors = session.execute(authors_query).scalars().all() + communities = session.execute(communities_query).scalars().all() return {"topics": topics, "authors": authors, "communities": communities}