From 391958e60ce93169517f741889953e4a32220905 Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 26 Nov 2023 15:37:22 +0300 Subject: [PATCH] schema-fix --- pyproject.toml | 2 +- resolvers/listener.py | 12 ++++++------ resolvers/schema.py | 9 +-------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f0ac0cb..1e18846 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ ensure_newline_before_comments = true line_length = 120 [tool.pyright] -include = ["orm", "resolvers"] +include = ["."] exclude = ["**/__pycache__"] ignore = [] defineConstant = { DEBUG = true } diff --git a/resolvers/listener.py b/resolvers/listener.py index fe6401b..f4d2f57 100644 --- a/resolvers/listener.py +++ b/resolvers/listener.py @@ -7,18 +7,18 @@ from services.rediscache import redis async def handle_reaction(notification: dict[str, str | int]): """создаеёт новое хранимое уведомление""" - try: - with local_session() as session: + with local_session() as session: + try: n = Notification(**notification) session.add(n) session.commit(n) - except Exception as e: - session.rollback() - print(f"[listener.handle_reaction] error: {str(e)}") + except Exception as e: + session.rollback() + print(f"[listener.handle_reaction] error: {str(e)}") async def reactions_worker(): async for message in redis.listen("reaction"): - msg = json.loads(message["data"]) + msg = json.loads((await message).get("data", "")) if msg: await handle_reaction(msg) diff --git a/resolvers/schema.py b/resolvers/schema.py index 3092ffe..c9b4a69 100644 --- a/resolvers/schema.py +++ b/resolvers/schema.py @@ -24,13 +24,6 @@ class Notification: occurrences: int -@strawberry.type -class NotificationsQueryResult: - notifications: list[Notification] - unread: int - total: int - - @strawberry.type class NotificationSeenResult: error: str @@ -40,7 +33,7 @@ class NotificationSeenResult: class NotificationsResult: notifications: List[Notification] unread: int - + total: int def notification_seen_by_viewer(viewer_id, notification_id, session): seen = (