from aiohttp import web from aiohttp_apispec import docs, querystring_schema from server.constants import BASE_API_PREFIX from server.scenarios.tracks import insights as scenarios from server.schemas.tracks.insights import TracksInsights from server.utils.response import dump_response_schema router = web.RouteTableDef() @router.get(BASE_API_PREFIX + "/tracks/insights/") @docs(tags=["streams", "tracks"], summary="Get tracks top country codes by streams.") @querystring_schema(TracksInsights.Request) @dump_response_schema(TracksInsights.Response(many=True), apply=False) async def get_tracks_insights(request: web.Request) -> list[dict]: return await scenarios.get_tracks_insights(**request["querystring"])