From ffb75e53f76bff9998eee1a32c22f16fcab8dc0f Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 2 Feb 2025 21:55:22 +0300 Subject: [PATCH] logs-update-shout-4 --- resolvers/editor.py | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/resolvers/editor.py b/resolvers/editor.py index 7d7aea1b..18774af7 100644 --- a/resolvers/editor.py +++ b/resolvers/editor.py @@ -461,34 +461,8 @@ async def update_shout(_, info, shout_id: int, shout_input=None, publish=False): for a in shout_by_id.authors: await cache_by_id(Author, a.id, cache_author) logger.info(f"shout#{shout_id} updated") - # Получаем полные данные шаута со связями - shout_with_relations = ( - session.query(Shout) - .options(joinedload(Shout.topics), joinedload(Shout.authors)) - .filter(Shout.id == shout_id) - .first() - ) - - shout_dict = shout_with_relations.dict() - # Явно добавляем связанные данные в словарь - shout_dict["topics"] = ( - [ - {"id": topic.id, "slug": topic.slug, "title": topic.title} - for topic in shout_with_relations.topics - ] - if shout_with_relations.topics - else [] - ) - - shout_dict["authors"] = ( - [ - {"id": author.id, "name": author.name, "slug": author.slug} - for author in shout_with_relations.authors - ] - if shout_with_relations.authors - else [] - ) - + # Используем уже обновленный объект shout_by_id вместо нового запроса + shout_dict = shout_by_id.dict() # dict() теперь включает все связи logger.info(f"Final shout data with relations: {shout_dict}") return {"shout": shout_dict, "error": None} else: