From 49fe665d4d695f8e0cb34b5b490367077e50a349 Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 17 Dec 2023 15:22:07 +0300 Subject: [PATCH] following-fix-4 --- resolvers/author.py | 3 ++- resolvers/follower.py | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/resolvers/author.py b/resolvers/author.py index a35e865a..13d50bce 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -166,7 +166,8 @@ async def get_author_id(_, _info, user: str): with local_session() as session: print(f"[resolvers.author] getting author id for {user}") a = session.query(Author).filter(Author.user == user).first() - print(f"[resolvers.author] got {a}") + if a: + print(f"[resolvers.author] got @{a.slug}") return a diff --git a/resolvers/follower.py b/resolvers/follower.py index bb5aebb1..778927fe 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -94,19 +94,15 @@ async def get_my_followed(_, info): with local_session() as session: author = session.query(Author).filter(Author.user == user_id).first() if author: - authors_query = ( - select(Author).join(AuthorFollower).filter(AuthorFollower.follower == author.id).from_(Author) - ) + authors_query = select(Author).join(AuthorFollower).filter(AuthorFollower.follower == author.id) - topics_query = select(Topic).join(TopicFollower).filter(TopicFollower.follower == author.id).from_(Author) + topics_query = select(Topic).join(TopicFollower).filter(TopicFollower.follower == author.id) - communities_query = ( - select(Community).join(CommunityAuthor).filter(CommunityAuthor.author == author.id).from_(Author) - ) + # communities_query = select(Community).join(CommunityAuthor).filter(CommunityAuthor.author == author.id) topics = session.execute(topics_query).scalars().all() authors = session.execute(authors_query).scalars().all() - communities = session.execute(communities_query).scalars().all() + communities = session.query(Community).scalars().all() return {"topics": topics, "authors": authors, "communities": communities}