notification-model-fix-2
This commit is contained in:
parent
ac424cf803
commit
eae0603df3
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
from services.db import local_session
|
from services.db import local_session
|
||||||
from resolvers.model import (
|
from resolvers.model import (
|
||||||
NotificationReaction,
|
NotificationReaction,
|
||||||
|
@ -11,6 +12,7 @@ from typing import Dict, List
|
||||||
import time, json
|
import time, json
|
||||||
import strawberry
|
import strawberry
|
||||||
from sqlalchemy.orm import aliased
|
from sqlalchemy.orm import aliased
|
||||||
|
from sqlalchemy.sql.expression import or_
|
||||||
from sqlalchemy import select, and_
|
from sqlalchemy import select, and_
|
||||||
import logging
|
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] = {}
|
groups_by_thread: Dict[str, NotificationGroup] = {}
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
total = session.query(Notification).filter(and_(Notification.action == NotificationAction.CREATE.value, Notification.created_at > after)).count()
|
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)
|
notifications_result = session.execute(query)
|
||||||
for n, seen in notifications_result:
|
for n, seen in notifications_result:
|
||||||
thread_id = ""
|
thread_id = ""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user