get-author-fix
All checks were successful
Deploy on push / deploy (push) Successful in 24s

This commit is contained in:
Untone 2024-02-26 01:06:10 +03:00
parent f12d2fc560
commit 152730526f

View File

@ -38,9 +38,7 @@ def get_authors_all(_, _info):
@query.field('get_author')
async def get_author(_, _info, slug='', author_id=None):
q = None
author = None
cache = None
try:
if slug:
@ -52,12 +50,11 @@ 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())
if not author:
q = select(Author).where(Author.id == author_id)
[author] = get_with_stat(q)
if author:
await update_author_cache(author.dict())
except Exception as exc:
logger.error(exc)
return author