diff --git a/resolvers/load.py b/resolvers/load.py index 10b4e35..54bad15 100644 --- a/resolvers/load.py +++ b/resolvers/load.py @@ -1,3 +1,4 @@ + from services.db import local_session from resolvers.model import ( NotificationReaction, @@ -11,6 +12,7 @@ from typing import Dict, List import time, json import strawberry from sqlalchemy.orm import aliased +from sqlalchemy.sql.expression import or_ from sqlalchemy import select, and_ import logging @@ -60,7 +62,13 @@ async def get_notifications_grouped(author_id: int, after: int = 0, limit: int = groups_by_thread: Dict[str, NotificationGroup] = {} with local_session() as session: total = session.query(Notification).filter(and_(Notification.action == NotificationAction.CREATE.value, Notification.created_at > after)).count() - unread = session.query(Notification).filter(and_(Notification.action == NotificationAction.CREATE.value, Notification.created_at > after, Notification.seen.is_not(True))).count() + unread = session.query(Notification).filter( + and_( + Notification.action == NotificationAction.CREATE.value, + Notification.created_at > after, + or_(Notification.seen.is_(False), Notification.seen.is_(None)) + ) + ).count() notifications_result = session.execute(query) for n, seen in notifications_result: thread_id = ""