From d8c3f804511202ba4667389ce3cf168f835ed9e0 Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 13 Oct 2023 15:48:53 +0300 Subject: [PATCH] debug-core-conector --- resolvers/load.py | 8 +++----- services/core.py | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/resolvers/load.py b/resolvers/load.py index 1813630..c992085 100644 --- a/resolvers/load.py +++ b/resolvers/load.py @@ -44,7 +44,6 @@ async def load_messages(chat_id: str, limit: int = 5, offset: int = 0, ids=None) 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}") cids = (await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")) or [] members_online = (await redis.execute("SMEMBERS", "authors-online")) or [] cids = list(cids)[offset:(offset + limit)] @@ -53,13 +52,12 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0): 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}") + print(f"[resolvers.load] created chat: {r}") cids.append(r["chat"]["id"]) for cid in cids: - print(f"Processing chat ID: {cid}") async with lock: c = await redis.execute("GET", f"chats/{cid}") - print(f"GET result for chat {cid}: {c}") + print(f"[resolvers.load] redis GET by {cid}: {c}") if c: c = json.loads(c) c["messages"] = await load_messages(cid, 5, 0) @@ -68,7 +66,7 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0): c["members"] = [] for member_id in member_ids: a = await get_author(member_id) - print(f"{a}") + print(f"[resolvers.load] author with id={member_id}: {a}") if a: c["members"].append( { diff --git a/services/core.py b/services/core.py index bac740e..056ef1f 100644 --- a/services/core.py +++ b/services/core.py @@ -16,6 +16,7 @@ async def get_author(author_id): try: async with AsyncClient() as client: response = await client.post(API_BASE, headers=headers, data=gql) + print(f"[services.core] get_author response: {response.status_code} {response.text}") if response.status_code != 200: return None r = response.json()