Spaces:
Running on T4
Running on T4
Download backend/app/modules/goals/controller.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/modules/goals/controller.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/app/modules/goals/controller.py
-
curl -L -o controller.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/modules/goals/controller.py
1.73 kB
| """N16-N19: goals and milestones.""" | |
| from typing import Annotated | |
| from uuid import UUID | |
| from fastapi import APIRouter, Depends, Query | |
| from app.common.academy_access import CurrentStaff | |
| from app.common.schemas import Page | |
| from app.core.dependencies import CurrentAccount, CurrentPlayer, Db, Paging | |
| from app.integrations.push import PushClient, get_push_client | |
| from app.modules.goals.schemas import GoalEnvelope, GoalHistoryOut, GoalIn, MilestoneOut, Mode | |
| from app.modules.goals.service import GoalService | |
| router = APIRouter(prefix="/v1", tags=["goals"]) | |
| ModeQuery = Annotated[Mode, Query()] | |
| async def get_goal(player_id: UUID, mode: ModeQuery, account: CurrentAccount, db: Db) -> GoalEnvelope: | |
| return await GoalService(db).current(account, player_id, mode) | |
| async def put_goal(player_id: UUID, mode: Mode, body: GoalIn, staff: CurrentStaff, db: Db, | |
| push: Annotated[PushClient, Depends(get_push_client)]) -> GoalEnvelope: | |
| return await GoalService(db, push).set(staff, player_id, mode, body) | |
| async def goal_history(player_id: UUID, mode: ModeQuery, account: CurrentAccount, db: Db, | |
| paging: Paging) -> Page[GoalHistoryOut]: | |
| return await GoalService(db).history(account, player_id, mode, paging) | |
| async def milestones(mode: ModeQuery, player: CurrentPlayer, db: Db, paging: Paging) -> Page[MilestoneOut]: | |
| return await GoalService(db).milestones(player, mode, paging) | |