groupby-fix
All checks were successful
Deploy to core / deploy (push) Successful in 1m23s

This commit is contained in:
2024-02-23 00:03:12 +03:00
parent 54f7dd9c1f
commit b0e2551e9b
4 changed files with 9 additions and 10 deletions

View File

@@ -8,8 +8,7 @@ from services.db import local_session
# from services.viewed import ViewedStorage
def add_author_stat_columns(q, author_model=None):
aliased_author = author_model or aliased(Author)
def add_author_stat_columns(q):
shout_author_aliased = aliased(ShoutAuthor)
q = q.outerjoin(shout_author_aliased).add_columns(
func.count(distinct(shout_author_aliased.shout)).label('shouts_stat')
@@ -17,15 +16,15 @@ def add_author_stat_columns(q, author_model=None):
authors_table = aliased(AuthorFollower)
q = q.outerjoin(
authors_table, authors_table.follower == aliased_author.id
authors_table, authors_table.follower == Author.id
).add_columns(func.count(distinct(authors_table.author)).label('authors_stat'))
followers_table = aliased(AuthorFollower)
q = q.outerjoin(followers_table, followers_table.author == aliased_author.id).add_columns(
q = q.outerjoin(followers_table, followers_table.author == Author.id).add_columns(
func.count(distinct(followers_table.follower)).label('followers_stat')
)
q = q.group_by(aliased_author.id)
q = q.group_by(Author.id)
return q