From b2fdc9a4535fea9f305876af8566d31a2d71215a Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 11 Jun 2024 14:46:10 +0300 Subject: [PATCH] parser-fix --- resolvers/author.py | 3 +-- resolvers/community.py | 9 +++------ services/triggers.py | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/resolvers/author.py b/resolvers/author.py index 9abb81be..589f12f0 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -114,8 +114,7 @@ async def load_authors_by(_, _info, by, limit, offset): authors_query = authors_query.filter(Author.name.ilike(f"%{by['name']}%")) elif by.get("topic"): authors_query = ( - authors_query - .join(ShoutAuthor) # Первое соединение ShoutAuthor + authors_query.join(ShoutAuthor) # Первое соединение ShoutAuthor .join(ShoutTopic, ShoutAuthor.shout == ShoutTopic.shout) .join(Topic, ShoutTopic.topic == Topic.id) .filter(Topic.slug == str(by["topic"])) diff --git a/resolvers/community.py b/resolvers/community.py index 83bfc876..ffc51316 100644 --- a/resolvers/community.py +++ b/resolvers/community.py @@ -1,8 +1,7 @@ -from sqlalchemy import distinct, func, select +from sqlalchemy import select from orm.author import Author from orm.community import Community -from orm.shout import ShoutCommunity from services.db import local_session from services.schema import query @@ -12,11 +11,9 @@ def get_communities_from_query(q): with local_session() as session: for [c, shouts_stat, followers_stat] in session.execute(q): c.stat = { - "shouts": session.execute( - select(func.count(distinct(ShoutCommunity.shout))).filter(ShoutCommunity.community == c.id) - ), + "shouts": shouts_stat, + "followers": followers_stat, # "authors": session.execute(select(func.count(distinct(ShoutCommunity.shout))).filter(ShoutCommunity.community == c.id)), - # "followers": session.execute(select(func.count(distinct(ShoutCommunity.shout))).filter(ShoutCommunity.community == c.id)), # "commented": commented_stat, } ccc.append(c) diff --git a/services/triggers.py b/services/triggers.py index e9f692a4..a9834f0f 100644 --- a/services/triggers.py +++ b/services/triggers.py @@ -34,7 +34,7 @@ async def handle_topic_follower_change(topic_id: int, follower_id: int, is_inser topic = get_with_stat(topic_query) follower_query = select(Author).filter(Author.id == follower_id) follower = get_with_stat(follower_query) - if isinstance(follower[0],Author) and isinstance(topic[0], Topic): + if isinstance(follower[0], Author) and isinstance(topic[0], Topic): topic = topic[0] follower = follower[0] await cache_topic(topic.dict())