qfa.api.routes_usage#

API route handlers for the usage-tracking endpoints.

Owns its own APIRouter; mounted by create_app alongside the main router. Carved out of routes.py so the analyze/summarize/coding flow isn’t interleaved with usage-stat marshalling.

Functions

usage(tenant, usage_repo, from_, to)

Usage statistics for the authenticated tenant within an optional window.

usage_all(_tenant, usage_repo, from_, to)

Per-tenant and grand-total usage statistics.

async qfa.api.routes_usage.usage(tenant: TenantApiKey = Depends(dependency=<function authenticate_request>, use_cache=True, scope=None), usage_repo: UsageRepositoryPort = Depends(dependency=<function get_usage_repo>, use_cache=True, scope=None), from_: datetime | None = Query(None), to: datetime | None = Query(None)) UsageStatsResponse[source]#

Usage statistics for the authenticated tenant within an optional window.

Parameters:
  • tenant (TenantApiKey) – The authenticated tenant.

  • usage_repo (UsageRepositoryPort) – The usage repository.

  • from (datetime | None) – Inclusive lower bound (UTC tz-aware), or None.

  • to (datetime | None) – Exclusive upper bound (UTC tz-aware), or None.

Returns:

Aggregated usage statistics for the tenant in the time window.

Return type:

UsageStatsResponse

async qfa.api.routes_usage.usage_all(_tenant: TenantApiKey = Depends(dependency=<function require_superuser>, use_cache=True, scope=None), usage_repo: UsageRepositoryPort = Depends(dependency=<function get_usage_repo>, use_cache=True, scope=None), from_: datetime | None = Query(None), to: datetime | None = Query(None)) AllUsageStatsResponse[source]#

Per-tenant and grand-total usage statistics. Requires superuser access.

Parameters:
  • _tenant (TenantApiKey) – The authenticated superuser tenant.

  • usage_repo (UsageRepositoryPort) – The usage repository.

  • from (datetime | None) – Inclusive lower bound (UTC tz-aware), or None.

  • to (datetime | None) – Exclusive upper bound (UTC tz-aware), or None.

Returns:

Per-tenant and grand total usage statistics within the window.

Return type:

AllUsageStatsResponse