diff --git a/resolvers/follower.py b/resolvers/follower.py index 6780fadf..c8fcb2f5 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -73,7 +73,7 @@ async def follow(_, info, what, slug): elif what == "COMMUNITY": with local_session() as session: - follows = session.execute(select(Community)) + follows = session.query(Community).all() elif what == "SHOUT": error = reactions_follow(follower_id, slug) diff --git a/resolvers/stat.py b/resolvers/stat.py index 3c434e42..d17c3511 100644 --- a/resolvers/stat.py +++ b/resolvers/stat.py @@ -12,7 +12,9 @@ from services.logger import root_logger as logger def add_topic_stat_columns(q): aliased_shout = aliased(ShoutTopic) - q = q.outerjoin(aliased_shout).add_columns(func.count(distinct(aliased_shout.shout)).label("shouts_stat")) + q = q.outerjoin(aliased_shout, and_(aliased_shout.shout == Shout.id, Shout.deleted_at.is_(None))).add_columns( + func.count(distinct(aliased_shout.shout)).label("shouts_stat") + ) aliased_follower = aliased(TopicFollower) q = q.outerjoin(aliased_follower, aliased_follower.topic == Topic.id).add_columns( func.count(distinct(aliased_follower.follower)).label("followers_stat") @@ -25,7 +27,9 @@ def add_topic_stat_columns(q): def add_author_stat_columns(q): aliased_shout = aliased(ShoutAuthor) - q = q.outerjoin(aliased_shout).add_columns(func.count(distinct(aliased_shout.shout)).label("shouts_stat")) + q = q.outerjoin(aliased_shout, and_(aliased_shout.shout == Shout.id, Shout.deleted_at.is_(None))).add_columns( + func.count(distinct(aliased_shout.shout)).label("shouts_stat") + ) aliased_follower = aliased(AuthorFollower) q = q.outerjoin(aliased_follower, aliased_follower.author == Author.id).add_columns( func.count(distinct(aliased_follower.follower)).label("followers_stat")