get-followers-scalar-fix
All checks were successful
Deploy on push / deploy (push) Successful in 28s
All checks were successful
Deploy on push / deploy (push) Successful in 28s
This commit is contained in:
parent
a993741cf2
commit
129c4bccf4
|
@ -219,20 +219,21 @@ async def get_author_followers(_, _info, slug: str):
|
||||||
try:
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
author_alias = aliased(Author)
|
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()
|
||||||
cached = await redis.execute('GET', f'id:{author_id}:followers')
|
if author_id:
|
||||||
results = []
|
cached = await redis.execute('GET', f'id:{author_id}:followers')
|
||||||
if not cached:
|
results = []
|
||||||
author_follower_alias = aliased(AuthorFollower, name='af')
|
if not cached:
|
||||||
q = select(Author).join(
|
author_follower_alias = aliased(AuthorFollower, name='af')
|
||||||
author_follower_alias,
|
q = select(Author).join(
|
||||||
and_(
|
author_follower_alias,
|
||||||
author_follower_alias.author == author_id,
|
and_(
|
||||||
author_follower_alias.follower == Author.id,
|
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
|
results = get_with_stat(q)
|
||||||
|
return json.loads(cached) if cached else results
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
import traceback
|
import traceback
|
||||||
logger.error(exc)
|
logger.error(exc)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user