.dict-fxt
Some checks failed
Deploy on push / deploy (push) Failing after 6s

This commit is contained in:
Untone 2024-02-29 10:02:29 +03:00
parent ad5b4a81c3
commit caf45f3d42
2 changed files with 9 additions and 1 deletions

View File

@ -50,7 +50,12 @@ async def get_author(_, _info, slug='', author_id=None):
cache = await redis.execute('GET', f'id:{author_id}:author')
logger.debug(f'result from cache: {cache}')
q = select(Author).where(Author.id == author_id)
author_dict = json.loads(cache) if cache else get_with_stat(q)[0].dict()
author_dict = None
if cache:
author_dict = json.loads(cache)
else:
[author] = get_with_stat(q)
author_dict = author.dict()
logger.debug(f'author to be stored: {author_dict}')
if author:
await update_author_cache(author_dict)

View File

@ -57,6 +57,9 @@ class Base(declarative_base()):
data[c] = json.loads(str(value))
else:
data[c] = value
# Add synthetic field .stat
if hasattr(self, 'stat'):
data['stat'] = self.stat
return data
except Exception as e:
logger.error(f'Error occurred while converting object to dictionary: {e}')