From f16f3450402aad72bcf588f75885e20de16d18b1 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 23 Feb 2024 22:14:08 +0300 Subject: [PATCH] topics-with-stat-fix --- resolvers/stat.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/resolvers/stat.py b/resolvers/stat.py index a6462678..5fb6f8ba 100644 --- a/resolvers/stat.py +++ b/resolvers/stat.py @@ -164,6 +164,7 @@ def author_follows_authors(author_id: int): return authors + def author_follows_topics(author_id: int): subquery_shout_topic = ( select( @@ -202,31 +203,30 @@ def author_follows_topics(author_id: int): select( [ Topic, - func.coalesce(subquery_shout_topic.columns.shouts_stat, 0).label('shouts_stat'), - func.coalesce(subquery_shout_topic_authors.columns.authors_stat, 0).label('authors_stat'), - func.coalesce(subquery_topic_followers.columns.followers_stat, 0).label('followers_stat'), + subquery_shout_topic.columns.shouts_stat, + subquery_shout_topic_authors.columns.authors_stat, + subquery_topic_followers.columns.followers_stat, ] ) .select_from(Topic) .outerjoin( subquery_shout_topic, - Topic.id == subquery_shout_topic.columns.topic, - ) + Topic.id == subquery_shout_topic.c.topic, + ) .outerjoin( subquery_shout_topic_authors, - Topic.id == subquery_shout_topic_authors.columns.topic, - ) + Topic.id == subquery_shout_topic_authors.c.topic, + ) .outerjoin( subquery_topic_followers, - Topic.id == subquery_topic_followers.columns.topic, - ) + Topic.id == subquery_topic_followers.c.topic, + ) ) topics = execute_with_ministat(topics_query) return topics - def query_follows(author_id: int): try: topics = author_follows_topics(author_id)