From 5478ff45e7ec7d08dccde110a7ec67deb20d6c77 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 26 Feb 2024 02:07:46 +0300 Subject: [PATCH] get-author-fix-3 --- resolvers/author.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resolvers/author.py b/resolvers/author.py index 8cd9ae66..1588f906 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -49,13 +49,13 @@ async def get_author(_, _info, slug='', author_id=None): if author_id: cache = await redis.execute('GET', f'id:{author_id}:author') - author = json.loads(cache) - if not author: - q = select(Author).where(Author.id == author_id) - [author] = get_with_stat(q) - if author: - await update_author_cache(author.dict()) + author = json.loads(cache) if cache else get_with_stat(select(Author).where(Author.id == author_id)).first() + if author: + await update_author_cache(author.dict()) except Exception as exc: + import traceback + + traceback.print_exc() logger.error(exc) return author