get-my-followed-fix
Some checks failed
deploy / deploy (push) Failing after 4s

This commit is contained in:
2024-01-18 15:12:40 +03:00
parent 9812b308b3
commit 4320c9674c
2 changed files with 8 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ from typing import List
import logging
from sqlalchemy import select
from sqlalchemy.orm import aliased
from orm.author import Author, AuthorFollower
from orm.community import Community
@@ -103,12 +104,13 @@ 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, AuthorFollower.follower == Author.id)
.filter(AuthorFollower.follower == author.id)
)
aliased_authors = aliased(Author)
authors_query = (
session.query(aliased_authors)
.join(AuthorFollower, AuthorFollower.follower == author.id)
.filter(AuthorFollower.author == aliased_authors.id)
)
topics_query = select(Topic).join(TopicFollower, TopicFollower.follower == Author.id)
for [author] in session.execute(authors_query):