From ece6a3410c5292fdd53caa4d1b378e0e2b401fcd Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Mon, 31 Oct 2022 16:03:48 +0200 Subject: [PATCH] fix-authors --- resolvers/profile.py | 12 +++++++----- services/zine/shoutscache.py | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/resolvers/profile.py b/resolvers/profile.py index 4ff7f811..f5814d8b 100644 --- a/resolvers/profile.py +++ b/resolvers/profile.py @@ -197,11 +197,13 @@ def author_unfollow(user, slug): @query.field("authorsAll") async def get_authors_all(_, _info): - authors = await UserStorage.get_all_users() - authorslugs = ShoutsCache.by_author.keys() - authors = filter(lambda a: a.emailConfirmed and a.slug in authorslugs, authors) - for author in authors: - author.stat = await get_author_stat(author.slug) + users = await UserStorage.get_all_users() + authorslugs = await ShoutsCache.get_all_authors_slugs() + authors = [] + for author in users: + if author.slug in authorslugs: + author.stat = await get_author_stat(author.slug) + authors.append(author) return authors diff --git a/services/zine/shoutscache.py b/services/zine/shoutscache.py index 954c0984..40407114 100644 --- a/services/zine/shoutscache.py +++ b/services/zine/shoutscache.py @@ -251,6 +251,11 @@ class ShoutsCache: shouts_by_rating.sort(lambda s: s.stat["rating"], reverse=True) return shouts_by_rating + @staticmethod + async def get_all_authors_slugs(): + slugs = ShoutsCache.by_author.keys() + return slugs + @staticmethod async def worker(): while True: