auth-connector-fix
Some checks failed
deploy / deploy (push) Failing after 1m4s

This commit is contained in:
2023-12-17 09:43:45 +03:00
parent 1ea9332a98
commit f061d8a523
2 changed files with 28 additions and 8 deletions

View File

@@ -8,9 +8,13 @@ from services.db import local_session
from strawberry_sqlalchemy_mapper import StrawberrySQLAlchemyMapper
import strawberry
from strawberry.schema.config import StrawberryConfig
import logging
strawberry_sqlalchemy_mapper = StrawberrySQLAlchemyMapper()
# Инициализация логгера
logger = logging.getLogger(__name__)
@strawberry_sqlalchemy_mapper.type(NotificationMessage)
class Notification:
@@ -81,8 +85,11 @@ class Query:
total=session.query(NotificationMessage).count(),
)
return nr
except SQLAlchemyError as ex:
print(f"[resolvers.schema] {ex}")
except Exception as ex:
import traceback
traceback.print_exc()
logger.error(f"[load_notifications] Ошибка при выполнении запроса к базе данных: {ex}")
return NotificationsResult(notifications=[], total=0, unread=0)
@@ -100,7 +107,9 @@ class Mutation:
session.commit()
except SQLAlchemyError as e:
session.rollback()
print(f"[mark_notification_as_read] error: {str(e)}")
logger.error(
f"[mark_notification_as_read] Ошибка при обновлении статуса прочтения уведомления: {str(e)}"
)
return NotificationSeenResult(error="cant mark as read")
return NotificationSeenResult()
@@ -119,7 +128,9 @@ class Mutation:
session.commit()
except SQLAlchemyError as e:
session.rollback()
print(f"[mark_all_notifications_as_read] error: {str(e)}")
logger.error(
f"[mark_all_notifications_as_read] Ошибка при обновлении статуса прочтения всех уведомлений: {str(e)}"
)
return NotificationSeenResult(error="cant mark as read")
return NotificationSeenResult()