This commit is contained in:
parent
495b296508
commit
5c41312b1d
|
@ -54,19 +54,21 @@ def get_authors_all(_, _info):
|
||||||
|
|
||||||
|
|
||||||
@query.field('get_author')
|
@query.field('get_author')
|
||||||
async def get_author(_, _info, slug='', author_id=None):
|
async def get_author(_, _info, slug='', author_id=0):
|
||||||
author_dict = None
|
author_dict = None
|
||||||
try:
|
try:
|
||||||
author_query = ''
|
author_query = ''
|
||||||
author = None
|
author = None
|
||||||
|
author_id = 0
|
||||||
author_dict = None
|
author_dict = None
|
||||||
if slug:
|
if slug:
|
||||||
author_query = select(Author).filter(Author.slug == slug)
|
author_query = select(Author).filter(Author.slug == slug)
|
||||||
[author] = await get_authors_with_stat_cached(author_query)
|
[author] = await get_authors_with_stat_cached(author_query)
|
||||||
logger.debug(f'found @{slug} with id {author_id}')
|
if author:
|
||||||
if isinstance(author, Author):
|
|
||||||
author_id = author.id
|
author_id = author.id
|
||||||
author_query = select(Author.id).filter(Author.id == author_id)
|
logger.debug(f'found @{slug} with id {author_id}')
|
||||||
|
if author_id:
|
||||||
|
author_query = select(Author).filter(Author.id == author_id)
|
||||||
cache_key = f'author:{author_id}'
|
cache_key = f'author:{author_id}'
|
||||||
cache = await redis.execute('GET', cache_key)
|
cache = await redis.execute('GET', cache_key)
|
||||||
if cache and isinstance(cache, str):
|
if cache and isinstance(cache, str):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user