From 49423ffb93b13c69f8b02accd86cbbf97d57f6fc Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 16 Oct 2023 19:00:18 +0300 Subject: [PATCH] unread-fix-2 --- services/unread.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/unread.py b/services/unread.py index 9132c32f..d0587021 100644 --- a/services/unread.py +++ b/services/unread.py @@ -9,11 +9,9 @@ async def get_unread_counter(chat_id: str, author_id: int) -> int: async def get_total_unread_counter(author_id: int) -> int: - chats = await redis.execute("SMEMBERS", f"chats_by_author/{author_id}") + chats_set = await redis.execute("SMEMBERS", f"chats_by_author/{author_id}") unread = 0 - if chats: - chats = json.loads(chats) - for chat_id in chats: - n = await get_unread_counter(chat_id.decode("utf-8"), author_id) - unread += n + for chat_id in list(chats_set): + n = await get_unread_counter(chat_id.decode("utf-8"), author_id) + unread += n return unread