This commit is contained in:
parent
b172b4ef84
commit
4630299a56
17
README.md
17
README.md
|
@ -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
|
||||
```
|
||||
|
|
|
@ -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!
|
||||
}
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user