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>
69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
"""Tracking query handlers — Phase 10.7."""
|
|
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.services.tracking import (
|
|
CustomerTrackingTokenService,
|
|
ProofOfDeliveryService,
|
|
TrackingSessionService,
|
|
)
|
|
from app.specifications.tracking import (
|
|
CustomerTrackingTokenListSpec,
|
|
ProofOfDeliveryListSpec,
|
|
TrackingSessionListSpec,
|
|
)
|
|
|
|
|
|
class TrackingQueries:
|
|
def __init__(self, session: AsyncSession) -> None:
|
|
self.sessions = TrackingSessionService(session)
|
|
self.pod = ProofOfDeliveryService(session)
|
|
self.tokens = CustomerTrackingTokenService(session)
|
|
|
|
async def get_session(self, tenant_id: UUID, session_id: UUID):
|
|
return await self.sessions.get(tenant_id, session_id)
|
|
|
|
async def list_sessions(
|
|
self,
|
|
tenant_id: UUID,
|
|
*,
|
|
offset: int,
|
|
limit: int,
|
|
spec: TrackingSessionListSpec | None,
|
|
):
|
|
return await self.sessions.list(
|
|
tenant_id, offset=offset, limit=limit, spec=spec
|
|
)
|
|
|
|
async def list_points(self, tenant_id: UUID, session_id: UUID, *, limit: int = 500):
|
|
return await self.sessions.list_points(tenant_id, session_id, limit=limit)
|
|
|
|
async def get_pod(self, tenant_id: UUID, pod_id: UUID):
|
|
return await self.pod.get(tenant_id, pod_id)
|
|
|
|
async def list_pods(
|
|
self,
|
|
tenant_id: UUID,
|
|
*,
|
|
offset: int,
|
|
limit: int,
|
|
spec: ProofOfDeliveryListSpec | None,
|
|
):
|
|
return await self.pod.list(tenant_id, offset=offset, limit=limit, spec=spec)
|
|
|
|
async def get_token(self, tenant_id: UUID, token_id: UUID):
|
|
return await self.tokens.get(tenant_id, token_id)
|
|
|
|
async def list_tokens(
|
|
self,
|
|
tenant_id: UUID,
|
|
*,
|
|
offset: int,
|
|
limit: int,
|
|
spec: CustomerTrackingTokenListSpec | None,
|
|
):
|
|
return await self.tokens.list(tenant_id, offset=offset, limit=limit, spec=spec)
|