From b58406866cdd101088ae676bea0546ee40b17cd4 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 11 Mar 2024 12:22:28 +0300 Subject: [PATCH] set_follows_authors_cache-fix --- services/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/cache.py b/services/cache.py index 87265167..b079888d 100644 --- a/services/cache.py +++ b/services/cache.py @@ -33,7 +33,7 @@ async def update_author_followers_cache(author_id: int, followers): async def set_follows_topics_cache(follows, author_id: int): try: - payload = json.dumps([a.dict() for a in follows], cls=CustomJSONEncoder) + payload = json.dumps([a.dict() if isinstance(a, Author) else a for a in follows], cls=CustomJSONEncoder) await redis.execute('SET', f'author:{author_id}:follows-topics', payload) except Exception as exc: logger.error(exc) @@ -45,7 +45,7 @@ async def set_follows_topics_cache(follows, author_id: int): async def set_follows_authors_cache(follows, author_id: int): try: - payload = json.dumps([a.dict() for a in follows], cls=CustomJSONEncoder) + payload = json.dumps([a.dict() if isinstance(a, Author) else a for a in follows], cls=CustomJSONEncoder) await redis.execute('SET', f'author:{author_id}:follows-authors', payload) except Exception as exc: import traceback