Coverage for kwai/api/v1/portal/endpoints/applications.py: 69%
16 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
1"""Module that implements applications endpoints."""
2from fastapi import APIRouter
4from kwai.api.dependencies import deps
5from kwai.api.schemas.application import (
6 ApplicationResource,
7)
8from kwai.core.db.database import Database
9from kwai.core.json_api import Meta
10from kwai.modules.portal.applications.application_db_repository import (
11 ApplicationDbRepository,
12)
13from kwai.modules.portal.get_applications import GetApplications, GetApplicationsCommand
15router = APIRouter()
18ApplicationResourceDocument = ApplicationResource.get_document_model()
21@router.get("/applications")
22async def get_applications(
23 db=deps.depends(Database),
24) -> ApplicationResourceDocument:
25 """Get all applications of kwai."""
26 command = GetApplicationsCommand()
27 count, application_iterator = await GetApplications(
28 ApplicationDbRepository(db)
29 ).execute(command)
31 result: ApplicationResourceDocument = ApplicationResource.serialize_list(
32 [ApplicationResource(application) async for application in application_iterator]
33 )
34 result.meta = Meta(count=count)
36 return result