From e75b37e1776e2692c5e4cc05d6e1d7833eb22abd Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 13 Oct 2023 12:50:00 +0300 Subject: [PATCH] redis-set-result-fix-2 --- resolvers/chats.py | 5 ----- resolvers/load.py | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/resolvers/chats.py b/resolvers/chats.py index 5f6cf99..fc4dfe5 100644 --- a/resolvers/chats.py +++ b/resolvers/chats.py @@ -52,8 +52,6 @@ async def create_chat(_, info, title="", members=None): if author_id not in members: members.append(int(author_id)) - await redis.execute('MULTI') - # NOTE: private chats has no title # reuse private chat created before if exists if len(members) == 2 and title == "": @@ -90,9 +88,6 @@ async def create_chat(_, info, title="", members=None): await redis.execute("SET", f"chats/{chat_id}", json.dumps(chat)) await redis.execute("SET", f"chats/{chat_id}/next_message_id", str(0)) - response = await redis.execute('EXEC') - print(f"EXEC response: {response}") - return {"error": None, "chat": chat} diff --git a/resolvers/load.py b/resolvers/load.py index c1e198a..b98b613 100644 --- a/resolvers/load.py +++ b/resolvers/load.py @@ -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}")