This commit is contained in:
parent
b3e7d24d9d
commit
499ecb501d
|
@ -154,12 +154,19 @@ async def load_authors_by(_, _info, by, limit, offset):
|
||||||
authors = []
|
authors = []
|
||||||
if authors_nostat:
|
if authors_nostat:
|
||||||
for [a] in authors_nostat:
|
for [a] in authors_nostat:
|
||||||
|
author_dict = None
|
||||||
if isinstance(a, Author):
|
if isinstance(a, Author):
|
||||||
author_id = a.id
|
author_id = a.id
|
||||||
if bool(author_id):
|
if bool(author_id):
|
||||||
cached_result = await redis.execute("GET", f"author:{author_id}")
|
cached_result = await redis.execute("GET", f"author:{author_id}")
|
||||||
if isinstance(cached_result, str):
|
if isinstance(cached_result, str):
|
||||||
author_dict = json.loads(cached_result)
|
author_dict = json.loads(cached_result)
|
||||||
|
if not author_dict or not isinstance(author_dict.get("shouts"), int):
|
||||||
|
author_query = q.filter(Author.id == author_id)
|
||||||
|
[author] = get_with_stat(author_query)
|
||||||
|
if author:
|
||||||
|
author_dict = author.dict()
|
||||||
|
if author_dict:
|
||||||
authors.append(author_dict)
|
authors.append(author_dict)
|
||||||
|
|
||||||
return authors
|
return authors
|
||||||
|
@ -315,7 +322,7 @@ async def get_author_followers(_, _info, slug: str):
|
||||||
if isinstance(followers_cached, list):
|
if isinstance(followers_cached, list):
|
||||||
logger.debug(f"@{slug} got {followers_cached} followers cached")
|
logger.debug(f"@{slug} got {followers_cached} followers cached")
|
||||||
for fc in followers_cached:
|
for fc in followers_cached:
|
||||||
if fc['id'] not in followers_ids:
|
if fc["id"] not in followers_ids:
|
||||||
followers.append(fc)
|
followers.append(fc)
|
||||||
return followers
|
return followers
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ def get_author_shouts_stat(author_id: int):
|
||||||
.filter(
|
.filter(
|
||||||
and_(
|
and_(
|
||||||
aliased_shout_author.author == author_id,
|
aliased_shout_author.author == author_id,
|
||||||
aliased_shout.published_at.is_not(None)
|
aliased_shout.published_at.is_not(None),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user