From 9307fc97fbde85f8fd8283dae31180031216c8be Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 30 May 2024 21:29:25 +0300 Subject: [PATCH] follower-topics-fix --- services/cache.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/cache.py b/services/cache.py index f1e27891..acabb0f4 100644 --- a/services/cache.py +++ b/services/cache.py @@ -203,14 +203,14 @@ async def get_cached_follower_topics(author_id: int): topics_ids = [topic.id for topic in topics] await redis.execute("SET", rkey, json.dumps(topics_ids)) - if not topics: - topics_objects = [] - for topic_id in topics_ids: - topic_str = await redis.execute("GET", f"topic:id:{topic_id}") - if topic_str: - topic = json.loads(topic_str) - if topic and topic not in topics_objects: - topics_objects.append(topic.dict()) + + topics = [] + for topic_id in topics_ids: + topic_str = await redis.execute("GET", f"topic:id:{topic_id}") + if topic_str: + topic = json.loads(topic_str) + if topic and topic not in topics: + topics.append(topic) logger.debug(f"author#{author_id} cache updated with {len(topics)} topics") return topics