diff --git a/resolvers/stat.py b/resolvers/stat.py index fe476981..a0ba1165 100644 --- a/resolvers/stat.py +++ b/resolvers/stat.py @@ -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')) ) diff --git a/resolvers/topic.py b/resolvers/topic.py index 0955614a..da75a611 100644 --- a/resolvers/topic.py +++ b/resolvers/topic.py @@ -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]