viewed-service-fixes
All checks were successful
deploy / deploy (push) Successful in 1m23s

This commit is contained in:
2023-12-17 23:30:20 +03:00
parent 2c6b872acb
commit a6c5243c06
20 changed files with 110 additions and 109 deletions

View File

@@ -2,14 +2,15 @@ from services.rediscache import redis
async def get_unread_counter(chat_id: str, author_id: int) -> int:
unread = await redis.execute("LLEN", f"chats/{chat_id}/unread/{author_id}")
return unread or 0
unread: int = await redis.execute("LLEN", f"chats/{chat_id}/unread/{author_id}") or 0
return unread
async def get_total_unread_counter(author_id: int) -> int:
chats_set = await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")
unread = 0
for chat_id in list(chats_set):
n = await get_unread_counter(chat_id, author_id)
unread += n
if chats_set:
for chat_id in list(chats_set):
n = await get_unread_counter(chat_id, author_id)
unread += n
return unread