From fa7b05a86e62ae8cc1955bf9a2b032e0dade8f5d Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 27 Feb 2024 16:42:26 +0300 Subject: [PATCH] get-author-followers-fix --- resolvers/author.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resolvers/author.py b/resolvers/author.py index 6905d66b..6986cdaf 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -225,6 +225,7 @@ async def get_author_followers(_, _info, slug: str): author = author_id_result[0] if author_id_result else None author_id = cast(author.id, Integer) cached = await redis.execute('GET', f'id:{author_id}:followers') + results = [] if not cached: author_follower_alias = aliased(AuthorFollower, name='af') q = select(Author).join( @@ -234,7 +235,8 @@ async def get_author_followers(_, _info, slug: str): author_follower_alias.follower == Author.id, ), ) - return json.loads(cached) if cached else get_with_stat(q) + results = get_with_stat(q) + return json.loads(cached) if cached else results except Exception as exc: import traceback logger.error(exc)