From ab36dfe233c3fed6f70fae9154c38f32aa7c78ef Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 14 Mar 2024 09:55:14 +0300 Subject: [PATCH] debug-get-author --- resolvers/author.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resolvers/author.py b/resolvers/author.py index 0a2e68f4..f4a052c9 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -45,6 +45,7 @@ async def get_author(_, _info, slug='', author_id=None): try: if slug: author_id = local_session().query(Author.id).filter(Author.slug == slug).scalar() + logger.debug(f'found @{slug} with id {author_id}') if author_id: cache_key = f'author:{author_id}' cache = await redis.execute('GET', cache_key) @@ -58,6 +59,11 @@ async def get_author(_, _info, slug='', author_id=None): if result: [author] = result author_dict = author.dict() + else: + logger.warn('author was not cached!') + author_query = select(Author).filter(Author.id == author_id) + author = get_with_stat(author_query) + author_dict = author.dict() logger.debug(f'author to be stored: {author_dict}') if author: await set_author_cache(author_dict)