This commit is contained in:
@@ -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()
|
||||
|
||||
|
Reference in New Issue
Block a user