logger-fix-getchat-fix
This commit is contained in:
parent
c96e8afc45
commit
6a450a84c1
|
@ -75,13 +75,13 @@ async def load_chats(
|
||||||
chats = []
|
chats = []
|
||||||
try:
|
try:
|
||||||
if author_id:
|
if author_id:
|
||||||
logger.debug("got author", author_id)
|
logger.debug(f"got author {author_id}")
|
||||||
cids = await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")
|
cids = await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")
|
||||||
logger.debug("got cids", cids)
|
logger.debug(f"got cids {cids}")
|
||||||
members_online = (
|
members_online = (
|
||||||
await redis.execute("SMEMBERS", "authors-online")
|
await redis.execute("SMEMBERS", "authors-online")
|
||||||
) or [] # to show online status
|
) or [] # to show online status
|
||||||
logger.debug("members online", members_online)
|
logger.debug(f"members online: {members_online}")
|
||||||
if isinstance(cids, set):
|
if isinstance(cids, set):
|
||||||
# TODO: add sort by chat.created_at with in-memory caching chats service
|
# TODO: add sort by chat.created_at with in-memory caching chats service
|
||||||
cids = list(cids)[offset : (offset + limit)]
|
cids = list(cids)[offset : (offset + limit)]
|
||||||
|
@ -89,9 +89,11 @@ async def load_chats(
|
||||||
if len(cids) == 0:
|
if len(cids) == 0:
|
||||||
logger.debug(f"no chats for user with id={author_id}")
|
logger.debug(f"no chats for user with id={author_id}")
|
||||||
r = await create_chat(None, info, members=[2]) # member with id = 2 is discours
|
r = await create_chat(None, info, members=[2]) # member with id = 2 is discours
|
||||||
if isinstance(r, dict) and "chat" in r:
|
if isinstance(r, dict) and "chat" in r and isinstance(r['chat'], dict):
|
||||||
logger.debug(f"created chat: {r['chat']['id']}")
|
chat_id = r['chat'].get('id')
|
||||||
cids.append(r["chat"]["id"])
|
if chat_id:
|
||||||
|
logger.debug(f"created chat: {chat_id}")
|
||||||
|
cids.append(chat_id)
|
||||||
|
|
||||||
logger.debug(f"getting data for {len(cids)} user's chats")
|
logger.debug(f"getting data for {len(cids)} user's chats")
|
||||||
for cid in cids:
|
for cid in cids:
|
||||||
|
|
|
@ -64,8 +64,8 @@ class CacheStorage:
|
||||||
self = CacheStorage
|
self = CacheStorage
|
||||||
async with self.lock:
|
async with self.lock:
|
||||||
result = get_all_authors()
|
result = get_all_authors()
|
||||||
logger.info(f"cache loaded {len(result)}")
|
if isinstance(result, list):
|
||||||
if result:
|
logger.info(f"cache loaded {len(result)}")
|
||||||
CacheStorage.authors = result
|
CacheStorage.authors = result
|
||||||
for a in result:
|
for a in result:
|
||||||
user_id = a.get("user")
|
user_id = a.get("user")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user