author-follows-result-type-debug
All checks were successful
Deploy on push / deploy (push) Successful in 21s
All checks were successful
Deploy on push / deploy (push) Successful in 21s
This commit is contained in:
parent
73c3d47f1b
commit
7f913050ee
|
@ -173,39 +173,39 @@ async def get_author_follows(_, _info, slug='', user=None, author_id=0):
|
||||||
author_query = author_query.filter(Author.id == author_id)
|
author_query = author_query.filter(Author.id == author_id)
|
||||||
else:
|
else:
|
||||||
raise ValueError('One of slug, user, or author_id must be provided')
|
raise ValueError('One of slug, user, or author_id must be provided')
|
||||||
# logger.debug(author_query)
|
[result] = local_session().execute(author_query)
|
||||||
result = local_session().execute(author_query)
|
if len(result) > 0:
|
||||||
logger.debug(result)
|
#logger.debug(result)
|
||||||
[author] = result
|
[author] = result
|
||||||
logger.debug(author)
|
#logger.debug(author)
|
||||||
if author and isinstance(author, Author):
|
if author and isinstance(author, Author):
|
||||||
logger.debug(author.dict())
|
logger.debug(author.dict())
|
||||||
author_id = author.id.scalar()
|
author_id = author.id.scalar()
|
||||||
rkey = f'author:{author_id}:follows-authors'
|
rkey = f'author:{author_id}:follows-authors'
|
||||||
logger.debug(f'getting {author_id} follows authors')
|
logger.debug(f'getting {author_id} follows authors')
|
||||||
cached = await redis.execute('GET', rkey)
|
cached = await redis.execute('GET', rkey)
|
||||||
if not cached:
|
if not cached:
|
||||||
authors = author_follows_authors(author_id)
|
authors = author_follows_authors(author_id)
|
||||||
prepared = [author.dict() for author in authors]
|
prepared = [author.dict() for author in authors]
|
||||||
await redis.execute('SET', rkey, json.dumps(prepared, cls=CustomJSONEncoder))
|
await redis.execute('SET', rkey, json.dumps(prepared, cls=CustomJSONEncoder))
|
||||||
elif isinstance(cached, str):
|
elif isinstance(cached, str):
|
||||||
authors = json.loads(cached)
|
authors = json.loads(cached)
|
||||||
|
|
||||||
rkey = f'author:{author_id}:follows-topics'
|
rkey = f'author:{author_id}:follows-topics'
|
||||||
cached = await redis.execute('GET', rkey)
|
cached = await redis.execute('GET', rkey)
|
||||||
if cached and isinstance(cached, str):
|
if cached and isinstance(cached, str):
|
||||||
topics = json.loads(cached)
|
topics = json.loads(cached)
|
||||||
if not cached:
|
if not cached:
|
||||||
topics = author_follows_topics(author_id)
|
topics = author_follows_topics(author_id)
|
||||||
prepared = [topic.dict() for topic in topics]
|
prepared = [topic.dict() for topic in topics]
|
||||||
await redis.execute('SET', rkey, json.dumps(prepared, cls=CustomJSONEncoder))
|
await redis.execute('SET', rkey, json.dumps(prepared, cls=CustomJSONEncoder))
|
||||||
return {
|
return {
|
||||||
'topics': topics,
|
'topics': topics,
|
||||||
'authors': authors,
|
'authors': authors,
|
||||||
'communities': [
|
'communities': [
|
||||||
{'id': 1, 'name': 'Дискурс', 'slug': 'discours', 'pic': ''}
|
{'id': 1, 'name': 'Дискурс', 'slug': 'discours', 'pic': ''}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user