diff --git a/resolvers/reaction.py b/resolvers/reaction.py index 3eb80350..b0c7b103 100644 --- a/resolvers/reaction.py +++ b/resolvers/reaction.py @@ -185,8 +185,8 @@ def prepare_new_rating(reaction: dict, shout_id: int, session, author: Author): @mutation.field('create_reaction') @login_required async def create_reaction(_, info, reaction): - user_id = info.context['user_id'] - + logger.debug(f'{info.context} for {reaction}') + user_id = info.context.get('user_id') shout_id = reaction.get('shout') if not shout_id: @@ -231,6 +231,7 @@ async def create_reaction(_, info, reaction): @mutation.field('update_reaction') @login_required async def update_reaction(_, info, reaction): + logger.debug(f'{info.context} for {reaction}') user_id = info.context.get('user_id') roles = info.context.get('roles') rid = reaction.get('id') @@ -289,6 +290,7 @@ async def update_reaction(_, info, reaction): @mutation.field('delete_reaction') @login_required async def delete_reaction(_, info, reaction_id: int): + logger.debug(f'{info.context} for {reaction_id}') user_id = info.context.get('user_id') roles = info.context.get('roles', []) if user_id: diff --git a/resolvers/stat.py b/resolvers/stat.py index d457b07a..23c71abd 100644 --- a/resolvers/stat.py +++ b/resolvers/stat.py @@ -192,13 +192,16 @@ def get_with_stat(q): with local_session() as session: for cols in session.execute(q): entity = cols[0] - entity.stat = {'shouts': cols[1], 'authors': cols[2], 'followers': cols[3]} + entity.stat = {} + entity.stat['shouts'] = cols[1] + entity.stat['authors'] = cols[2] + entity.stat['followers'] = cols[3] + entity.stat['comments'] = cols[4] if is_author: - entity.stat['comments'] = cols[4] entity.stat['topics'] = cols[5] # entity.stat['rating'] = cols[5] - cols[6] # entity.stat['rating_shouts'] = cols[7] - cols[8] - pass + records.append(entity) return records