Coverage for src/kwai/api/v1/trainings/endpoints/teams.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module for defining the trainings/teams API."""
3from fastapi import APIRouter, Depends
5from kwai.api.dependencies import create_database
6from kwai.api.v1.trainings.schemas.team import TeamDocument
7from kwai.core.json_api import Meta
8from kwai.modules.training.get_teams import GetTeams
9from kwai.modules.training.teams.team_db_repository import TeamDbRepository
12router = APIRouter()
15@router.get("/trainings/teams")
16async def get_teams(
17 database=Depends(create_database),
18) -> TeamDocument:
19 """Get teams."""
20 count, team_iterator = await GetTeams(TeamDbRepository(database)).execute()
22 document = TeamDocument(meta=Meta(count=count), data=[])
23 async for team in team_iterator:
24 document.merge(TeamDocument.create(team))
26 return document