From c78347b6f9321d307624e85ccf2204cc605d3988 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 1 Nov 2024 21:35:33 +0300 Subject: [PATCH] nodist2 --- resolvers/reader.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/resolvers/reader.py b/resolvers/reader.py index c761be6e..35007bba 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -62,11 +62,8 @@ def query_with_stat(info): :param info: Информация о контексте GraphQL :return: Запрос с подзапросом статистики. """ - # Основной запрос без GROUP BY - q = ( - select(Shout) - .join(Author, Author.id == Shout.created_by) - ) + # Основной запрос + q = select(Shout).join(Author, Author.id == Shout.created_by) # Создаем алиасы для всех таблиц main_author = aliased(Author) @@ -172,7 +169,7 @@ def query_with_stat(info): # Фильтр опубликованных q = q.where(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None))) - q = q.group_by(Shout.id) + q = q.group_by(Shout.id, Author.id) return q