renew-stat

This commit is contained in:
Untone 2024-03-28 19:21:57 +03:00
parent 9647ec9708
commit 0f57bea256

View File

@ -67,6 +67,12 @@ 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}')
else:
q = select(Author).where(Author.id == author_id)
[author] = await get_authors_with_stat_cached(q)