Coverage for apps/kwai-api/src/kwai_api/v1/portal/coaches/endpoints.py: 80%
15 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module that defines the coaches endpoints for the portal API."""
3from typing import Annotated
5from fastapi import APIRouter, Depends
6from kwai_bc_club.get_coaches import GetCoaches, GetCoachesCommand
7from kwai_bc_club.repositories.coach_db_repository import CoachDbRepository
8from kwai_core.db.database import Database
9from kwai_core.json_api import PaginationModel
11from kwai_api.dependencies import create_database
12from kwai_api.v1.portal.coaches.presenters import JsonApiCoachesPresenter
13from kwai_api.v1.portal.coaches.schemas import CoachesDocument
16router = APIRouter()
19@router.get("/coaches")
20async def get_coaches(
21 pagination: Annotated[PaginationModel, Depends(PaginationModel)],
22 database: Annotated[Database, Depends(create_database)],
23) -> CoachesDocument:
24 """Get all active coaches."""
25 presenter = JsonApiCoachesPresenter()
26 await GetCoaches(CoachDbRepository(database), presenter).execute(
27 GetCoachesCommand(offset=pagination.offset, limit=pagination.limit)
28 )
29 return presenter.get_document()