From c6df11dc7d6bbf37e46908dd978a53e583bed93b Mon Sep 17 00:00:00 2001 From: Untone Date: Sat, 17 Feb 2024 21:04:01 +0300 Subject: [PATCH] update-reaction-fix-2 --- resolvers/editor.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resolvers/editor.py b/resolvers/editor.py index fb012a9e..0ffc81a9 100644 --- a/resolvers/editor.py +++ b/resolvers/editor.py @@ -1,3 +1,4 @@ +import logging import time from sqlalchemy import and_, select @@ -17,6 +18,10 @@ from services.schema import mutation, query from services.search import search_service +logger = logging.getLogger('[resolver.editor]') +logger.setLevel(logging.DEBUG) + + @query.field('get_shouts_drafts') @login_required async def get_shouts_drafts(_, info): @@ -160,14 +165,15 @@ def patch_topics(session, shout, topics_input): @mutation.field('update_shout') @login_required -async def update_shout(_, info, shout_id, shout_input=None, publish=False): +async def update_shout(_, info, shout_input=None, publish=False): user_id = info.context['user_id'] roles = info.context['roles'] shout_input = shout_input or {} with local_session() as session: author = session.query(Author).filter(Author.user == user_id).first() current_time = int(time.time()) - if isinstance(author, Author): + shout_id = shout_input.get('id') + if isinstance(author, Author) and isinstance(shout_id, int): shout = ( session.query(Shout) .options( @@ -210,6 +216,8 @@ async def update_shout(_, info, shout_id, shout_input=None, publish=False): search_service.index(shout) return {'shout': shout_dict} + logger.debug(f' cannot update with data: {shout_input}') + return { 'error': 'not enough data' } return {'error': 'cannot update'}