join-clause-groupby-fixes
All checks were successful
Deploy to core / deploy (push) Successful in 1m6s

This commit is contained in:
Untone 2024-02-23 03:03:34 +03:00
parent 60c7ab5fe4
commit 8d97463c1d
2 changed files with 2 additions and 3 deletions

View File

@ -16,7 +16,7 @@ def add_topic_stat_columns(q):
.add_columns(func.count(distinct(ShoutTopic.shout)).label('shouts_stat'))
.outerjoin(aliased_shout_author, ShoutTopic.shout == aliased_shout_author.shout)
.add_columns(func.count(distinct(aliased_shout_author.author)).label('authors_stat'))
.outerjoin(aliased_topic_follower)
.outerjoin(aliased_topic_follower, aliased_topic_follower.topic == Topic.id)
.add_columns(func.count(distinct(aliased_topic_follower.follower)).label('followers_stat'))
)
@ -33,7 +33,7 @@ def add_author_stat_columns(q):
.add_columns(func.count(distinct(ShoutAuthor.shout)).label('shouts_stat'))
.outerjoin(aliased_author_authors, AuthorFollower.follower == Author.id)
.add_columns(func.count(distinct(aliased_author_authors.author)).label('authors_stat'))
.outerjoin(aliased_author_followers)
.outerjoin(aliased_author_followers, AuthorFollower.author == Author.id)
.add_columns(func.count(distinct(aliased_author_followers.follower)).label('followers_stat'))
)

View File

@ -37,7 +37,6 @@ def get_topics_by_author(_, _info, author_id=None, slug='', user=''):
@query.field('get_topic')
def get_topic(_, _info, slug):
q = select(Topic).filter(Topic.slug == slug)
q = q.group_by(Topic.id)
topics = get_topics_with_stat(q)
if topics:
return topics[0]