get-followers-scalar-fix
All checks were successful
Deploy on push / deploy (push) Successful in 28s

This commit is contained in:
Untone 2024-02-27 17:03:21 +03:00
parent a993741cf2
commit 129c4bccf4

View File

@ -219,7 +219,8 @@ async def get_author_followers(_, _info, slug: str):
try:
with local_session() as session:
author_alias = aliased(Author)
author_id = session.query(author_alias.id).filter(author_alias.slug == slug).first()
author_id = session.query(author_alias.id).filter(author_alias.slug == slug).scalar()
if author_id:
cached = await redis.execute('GET', f'id:{author_id}:followers')
results = []
if not cached:
@ -229,7 +230,7 @@ async def get_author_followers(_, _info, slug: str):
and_(
author_follower_alias.author == author_id,
author_follower_alias.follower == Author.id,
),
)
)
results = get_with_stat(q)
return json.loads(cached) if cached else results