unread-counter-fix
This commit is contained in:
parent
882ff39f28
commit
f5da6d450b
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user