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

This commit is contained in:
Untone 2024-02-23 13:52:31 +03:00
parent 595e4ba87d
commit 14e2828e2d

View File

@ -26,16 +26,16 @@ def add_topic_stat_columns(q):
def add_author_stat_columns(q): def add_author_stat_columns(q):
aliased_author_followers = aliased(AuthorFollower)
aliased_author_authors = aliased(AuthorFollower) aliased_author_authors = aliased(AuthorFollower)
aliased_author_followers = aliased(AuthorFollower) # Добавлен второй псевдоним
aliased_author = aliased(Author) aliased_author = aliased(Author)
q = ( q = (
q.outerjoin(ShoutAuthor, aliased_author.id == ShoutAuthor.author) q.outerjoin(ShoutAuthor, aliased_author.id == ShoutAuthor.author)
.add_columns(func.count(distinct(ShoutAuthor.shout)).label('shouts_stat')) .add_columns(func.count(distinct(ShoutAuthor.shout)).label('shouts_stat'))
.outerjoin(aliased_author_authors, AuthorFollower.follower == aliased_author.id) .outerjoin(aliased_author_authors, AuthorFollower.follower == aliased_author.id)
.add_columns(func.count(distinct(aliased_author_authors.author)).label('authors_stat')) .add_columns(func.count(distinct(aliased_author_authors.author)).label('authors_stat'))
.outerjoin(aliased_author_followers, AuthorFollower.author == aliased_author.id) .outerjoin(aliased_author_followers, AuthorFollower.author == aliased_author.id) # Используется второй псевдоним
.add_columns(func.count(distinct(aliased_author_followers.follower)).label('followers_stat')) .add_columns(func.count(distinct(aliased_author_followers.follower)).label('followers_stat')) # Используется второй псевдоним
) )
q = q.group_by(aliased_author.id) q = q.group_by(aliased_author.id)