Ship fleet, availability, pricing, dispatch, routing, tracking, and settlement on delivery-service 0.10.8.0 with migrations and phase tests green. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
"""Fleet query handlers — Phase 10.2."""
|
|
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.services.fleet import FleetService, VehicleService, VehicleTypeService
|
|
from app.specifications.fleet import FleetListSpec, VehicleListSpec, VehicleTypeListSpec
|
|
|
|
|
|
class FleetQueries:
|
|
def __init__(self, session: AsyncSession) -> None:
|
|
self.fleets = FleetService(session)
|
|
self.types = VehicleTypeService(session)
|
|
self.vehicles = VehicleService(session)
|
|
|
|
async def get_fleet(self, tenant_id: UUID, fleet_id: UUID):
|
|
return await self.fleets.get(tenant_id, fleet_id)
|
|
|
|
async def list_fleets(
|
|
self, tenant_id: UUID, *, offset: int, limit: int, spec: FleetListSpec | None
|
|
):
|
|
return await self.fleets.list(tenant_id, offset=offset, limit=limit, spec=spec)
|
|
|
|
async def get_vehicle_type(self, tenant_id: UUID, type_id: UUID):
|
|
return await self.types.get(tenant_id, type_id)
|
|
|
|
async def list_vehicle_types(
|
|
self, tenant_id: UUID, *, offset: int, limit: int, spec: VehicleTypeListSpec | None
|
|
):
|
|
return await self.types.list(tenant_id, offset=offset, limit=limit, spec=spec)
|
|
|
|
async def get_vehicle(self, tenant_id: UUID, vehicle_id: UUID):
|
|
return await self.vehicles.get(tenant_id, vehicle_id)
|
|
|
|
async def list_vehicles(
|
|
self, tenant_id: UUID, *, offset: int, limit: int, spec: VehicleListSpec | None
|
|
):
|
|
return await self.vehicles.list(tenant_id, offset=offset, limit=limit, spec=spec)
|
|
|
|
async def list_assignments(self, tenant_id: UUID, vehicle_id: UUID):
|
|
return await self.vehicles.list_assignments(tenant_id, vehicle_id)
|