debug-get-author

This commit is contained in:
Untone 2024-03-14 09:55:14 +03:00
parent 64b1498215
commit ab36dfe233

View File

@ -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)