From 736877d50ecbc40a7b43e49e56dc5f3eac327697 Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 28 Mar 2024 19:22:47 +0300 Subject: [PATCH] cached-stat-fix --- resolvers/author.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/resolvers/author.py b/resolvers/author.py index bcede27f..1d9c7f6c 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -67,12 +67,10 @@ async def get_author(_, _info, slug='', author_id=None): if cache and isinstance(cache, str): logger.debug(f'got cached author {cache_key} -> {cache}') author_dict = json.loads(cache) - if not author_dict.get('stat'): - logger.warn('author was cached without stat') - stat_str = await redis.execute('GET', f'author:{author_id}') - stat = json.loads(stat_str).get('stat') if isinstance(stat_str, str) else {} - author_dict['stat'] = stat - logger.info(f'stat updated {stat}') + stat_str = await redis.execute('GET', f'author:{author_id}') + stat = json.loads(stat_str).get('stat') if isinstance(stat_str, str) else {} + author_dict['stat'] = stat + logger.info(f'cached stat {stat}') else: q = select(Author).where(Author.id == author_id) [author] = await get_authors_with_stat_cached(q)