aliased
All checks were successful
Deploy to core / deploy (push) Successful in 2m1s

This commit is contained in:
Untone 2024-02-22 21:22:22 +03:00
parent ebf342c73b
commit 078e8ab7d1

View File

@ -3,6 +3,7 @@ import time
from typing import List from typing import List
from sqlalchemy import select, or_ from sqlalchemy import select, or_
from sqlalchemy.orm import aliased
from sqlalchemy.sql import and_ from sqlalchemy.sql import and_
from orm.author import Author, AuthorFollower from orm.author import Author, AuthorFollower
@ -90,13 +91,12 @@ def query_follows(user_id: str):
topics = [] topics = []
authors = [] authors = []
with local_session() as session: with local_session() as session:
aliased_author = aliased(Author)
author = ( author = (
session.query(Author).filter(Author.user == user_id).first() session.query(aliased_author).filter(aliased_author.user == user_id).first()
) )
if isinstance(author, Author): if isinstance(author, Author):
author_id = author.id author_id = author.id
session.commit()
authors_query = ( authors_query = (
select(Author) select(Author)
.join(AuthorFollower, AuthorFollower.follower == author_id) .join(AuthorFollower, AuthorFollower.follower == author_id)