get-author-fix
Some checks failed
Deploy on push / deploy (push) Failing after 7s

This commit is contained in:
Untone 2024-04-09 21:46:21 +03:00
parent 23288d1f91
commit d7db2689c8

View File

@ -55,13 +55,12 @@ async def get_author(_, _info, slug='', author_id=0):
try: try:
# lookup for cached author # lookup for cached author
author_query = select(Author).filter(or_(Author.slug == slug, Author.id == author_id)) author_query = select(Author).filter(or_(Author.slug == slug, Author.id == author_id))
[result]= local_session().execute(author_query) found_author = local_session().execute(author_query).first()
if result: logger.debug(found_author)
[found_author] = result if found_author:
logger.debug(found_author) logger.debug(f'found author id: {found_author.id}')
if found_author: author_id = found_author.id if found_author.id else author_id
logger.debug(f'found author id: {found_author.id}') if author_id:
author_id = found_author.id if not found_author.id else author_id
cached_result = await redis.execute('GET', f'author:{author_id}') cached_result = await redis.execute('GET', f'author:{author_id}')
author_dict = json.loads(cached_result) if cached_result else None author_dict = json.loads(cached_result) if cached_result else None