This commit is contained in:
Untone 2024-11-01 21:35:33 +03:00
parent 021765340a
commit c78347b6f9

View File

@ -62,11 +62,8 @@ def query_with_stat(info):
:param info: Информация о контексте GraphQL :param info: Информация о контексте GraphQL
:return: Запрос с подзапросом статистики. :return: Запрос с подзапросом статистики.
""" """
# Основной запрос без GROUP BY # Основной запрос
q = ( q = select(Shout).join(Author, Author.id == Shout.created_by)
select(Shout)
.join(Author, Author.id == Shout.created_by)
)
# Создаем алиасы для всех таблиц # Создаем алиасы для всех таблиц
main_author = aliased(Author) 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.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 return q