diff --git a/services/redis.py b/services/redis.py index 07a95e4b..2b6b3369 100644 --- a/services/redis.py +++ b/services/redis.py @@ -20,7 +20,7 @@ class RedisCache: print("[redis] " + command + " " + " ".join(args)) return await self._client.execute_command(command, *args, **kwargs) except Exception as e: - print(f"[redis] error: {e}" + command + " " + " ".join(args)) + print(f"[redis] ERROR: {e} with: " + command + " " + " ".join(args)) import traceback traceback.print_exc() diff --git a/services/unread.py b/services/unread.py index 676245a7..c679ef9f 100644 --- a/services/unread.py +++ b/services/unread.py @@ -15,11 +15,9 @@ async def get_unread_counter(chat_id: str, author_id: int): async def get_total_unread_counter(author_id: int): print(f"[services.unread] get_total_unread_counter({author_id})") - chats = await redis.execute("GET", f"chats_by_author/{author_id}") + chats = 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): + n = await get_unread_counter(chat_id.decode("utf-8"), author_id) + unread += n return unread