get-my-followed-fix-2

This commit is contained in:
Untone 2024-01-18 15:30:53 +03:00
parent 4320c9674c
commit 7b5330625b

View File

@ -104,14 +104,18 @@ async def get_my_followed(_, info):
with local_session() as session:
author = session.query(Author).filter(Author.user == user_id).first()
if author:
aliased_authors = aliased(Author)
author_id = int(author.id)
authors_query = (
session.query(aliased_authors)
.join(AuthorFollower, AuthorFollower.follower == author.id)
.filter(AuthorFollower.author == aliased_authors.id)
session.query(Author)
.join(AuthorFollower, AuthorFollower.follower == author_id)
.filter(AuthorFollower.author == Author.id)
)
topics_query = (
session.query(Topic)
.join(TopicFollower, TopicFollower.follower == author_id)
)
topics_query = select(Topic).join(TopicFollower, TopicFollower.follower == Author.id)
for [author] in session.execute(authors_query):
authors.append(author)
@ -124,6 +128,7 @@ async def get_my_followed(_, info):
return {"topics": topics, "authors": authors, "communities": communities}
@query.field("get_shout_followers")
def get_shout_followers(_, _info, slug: str = "", shout_id: int | None = None) -> List[Author]:
followers = []