redis-set-result-fix-2
This commit is contained in:
@@ -45,16 +45,15 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0):
|
||||
"""load :limit chats of current user with :offset"""
|
||||
author_id = info.context["author_id"]
|
||||
print(f"Loading chats for user with id={author_id}")
|
||||
await redis.execute('MULTI')
|
||||
cids = (await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")) or []
|
||||
members_online = (await redis.execute("SMEMBERS", "authors-online")) or []
|
||||
await redis.execute('EXEC')
|
||||
cids = list(cids)[offset:(offset + limit)]
|
||||
chats = []
|
||||
lock = asyncio.Lock()
|
||||
if len(cids) == 0:
|
||||
print(f"[resolvers.load] no chats for user with id={author_id}, create one with Discours (id=2)")
|
||||
r = await create_chat(None, info, members=[2]) # member with id = 2 is discours
|
||||
print(f"{r}")
|
||||
cids.append(r["chat"]["id"])
|
||||
for cid in cids:
|
||||
print(f"Processing chat ID: {cid}")
|
||||
|
Reference in New Issue
Block a user