schema-fix
Some checks failed
deploy / deploy (push) Failing after 1m41s

This commit is contained in:
Untone 2023-11-24 05:45:38 +03:00
parent b172b4ef84
commit 4630299a56
3 changed files with 60 additions and 9 deletions

View File

@ -3,7 +3,7 @@
### Что делает
- слушает redis PubSub каналы реакций и постов
- собирает уведомления
- сохраняет уведомления
- формирует дайджесты
@ -11,3 +11,18 @@
- не отправляет сообщения по SSE
- не определяет кому их отправлять
## Как разрабатывать локально
Установить
- Redis
- Postgres
Затем
```shell
poetry install
poetry env use 3.12
poetry run python server.py
```

View File

@ -0,0 +1,37 @@
enum NotificationAction {
CREATE,
UPDATE,
DELETE,
SEEN
}
enum NotificationEntity {
SHOUT,
REACTION
}
type Notification {
id: Int!
action: NotificationAction!
entity: NotificationEntity!
created_at: Int!
seen: Boolean!
data: String # JSON
occurrences: Int
}
input NotificationsQueryParams {
limit: Int
offset: Int
}
type NotificationsQueryResult {
notifications: [Notification]!
total: Int!
unread: Int!
}
type Query {
loadNotifications(params: NotificationsQueryParams!): NotificationsQueryResult!
}

View File

@ -5,6 +5,10 @@ from services.db import local_session
from services.schema import mutation, query
from orm.notification import Notification
# TODO: occurrencies?
# TODO: use of Author.id?
@query.field("loadNotifications")
@login_required
@ -16,12 +20,7 @@ async def load_notifications(_, info, params=None):
limit = params.get("limit", 50)
offset = params.get("offset", 0)
q = (
select(Notification)
.order_by(desc(Notification.created_at))
.limit(limit)
.offset(offset)
)
q = select(Notification).order_by(desc(Notification.created_at)).limit(limit).offset(offset)
notifications = []
with local_session() as session:
@ -39,8 +38,8 @@ async def load_notifications(_, info, params=None):
return {
"notifications": notifications,
"totalCount": total_count,
"totalUnreadCount": total_unread_count,
"total": total_count,
"unread": total_unread_count,
}