Spaces:
Running on T4
Running on T4
Download backend/app/modules/notifications/controller.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/modules/notifications/controller.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/app/modules/notifications/controller.py
-
curl -L -o controller.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/modules/notifications/controller.py
1.4 kB
| """N06 to N09: /notifications.""" | |
| from uuid import UUID | |
| from fastapi import APIRouter, Response | |
| from app.common.schemas import Page | |
| from app.core.dependencies import CurrentAccount, Db, Paging | |
| from app.modules.notifications.schemas import NotificationOut, ReadAllIn, UnreadCount | |
| from app.modules.notifications.service import NotificationService | |
| router = APIRouter(prefix="/v1", tags=["notifications"]) | |
| async def list_notifications(account: CurrentAccount, db: Db, paging: Paging) -> Page[NotificationOut]: | |
| return await NotificationService(db).list(account, paging) | |
| async def unread_count(account: CurrentAccount, db: Db) -> UnreadCount: | |
| return await NotificationService(db).unread_count(account) | |
| async def read_all(account: CurrentAccount, db: Db, body: ReadAllIn | None = None) -> Response: | |
| await NotificationService(db).mark_all_read(account, body.through if body else None) | |
| return Response(status_code=204) | |
| async def read_one(notification_id: UUID, account: CurrentAccount, db: Db) -> Response: | |
| await NotificationService(db).mark_read(account, notification_id) | |
| return Response(status_code=204) | |