From b3eda4a0e1d95b76b398f24f57bd4568c316825e Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 9 Apr 2024 13:32:11 +0300 Subject: [PATCH] result-fix --- resolvers/author.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/resolvers/author.py b/resolvers/author.py index 74143bba..cf037be3 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -55,13 +55,15 @@ async def get_author(_, _info, slug='', author_id=0): try: # lookup for cached author author_query = select(Author).filter(or_(Author.slug == slug, Author.id == author_id)) - [found_author] = local_session().execute(author_query) - logger.debug(found_author) - if found_author: - logger.debug(f'found author id: {found_author.id}') - author_id = found_author.id if not found_author.id else author_id - cached_result = await redis.execute('GET', f'author:{author_id}') - author_dict = json.loads(cached_result) if cached_result else None + [result]= local_session().execute(author_query) + if result: + [found_author] = result + logger.debug(found_author) + if found_author: + logger.debug(f'found author id: {found_author.id}') + author_id = found_author.id if not found_author.id else author_id + cached_result = await redis.execute('GET', f'author:{author_id}') + author_dict = json.loads(cached_result) if cached_result else None # update stat from db if not author_dict or not author_dict.get('stat'):