This commit is contained in:
parent
dd0c5d15fd
commit
b3eda4a0e1
|
@ -55,13 +55,15 @@ 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))
|
||||||
[found_author] = local_session().execute(author_query)
|
[result]= local_session().execute(author_query)
|
||||||
logger.debug(found_author)
|
if result:
|
||||||
if found_author:
|
[found_author] = result
|
||||||
logger.debug(f'found author id: {found_author.id}')
|
logger.debug(found_author)
|
||||||
author_id = found_author.id if not found_author.id else author_id
|
if found_author:
|
||||||
cached_result = await redis.execute('GET', f'author:{author_id}')
|
logger.debug(f'found author id: {found_author.id}')
|
||||||
author_dict = json.loads(cached_result) if cached_result else None
|
author_id = found_author.id if not found_author.id else author_id
|
||||||
|
cached_result = await redis.execute('GET', f'author:{author_id}')
|
||||||
|
author_dict = json.loads(cached_result) if cached_result else None
|
||||||
|
|
||||||
# update stat from db
|
# update stat from db
|
||||||
if not author_dict or not author_dict.get('stat'):
|
if not author_dict or not author_dict.get('stat'):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user