notifications fixes

This commit is contained in:
Igor Lobanov
2023-10-13 17:15:14 +02:00
parent 43542754b9
commit 6dbd5918c4
3 changed files with 29 additions and 21 deletions

View File

@@ -23,6 +23,7 @@ async def load_notifications(_, info, params=None):
Notification.user == user_id
).order_by(desc(Notification.createdAt)).limit(limit).offset(offset)
notifications = []
with local_session() as session:
total_count = session.query(Notification).where(
Notification.user == user_id
@@ -31,11 +32,13 @@ async def load_notifications(_, info, params=None):
total_unread_count = session.query(Notification).where(
and_(
Notification.user == user_id,
Notification.seen is False
Notification.seen == False
)
).count()
notifications = session.execute(q).fetchall()
for [notification] in session.execute(q):
notification.type = notification.type.name
notifications.append(notification)
return {
"notifications": notifications,