Analytics
Analytics
api/views/analytics_views.py exposes the dashboard aggregate endpoints.
Endpoint family
GET /api/v1/analytics/summary/GET /api/v1/analytics/by-model/GET /api/v1/analytics/by-document/GET /api/v1/analytics/tokens/
Data sources
Analytics reads primarily from:
ProcessingDocumentfor document totals and processing timesAIStudioProcessingfor model usage and token metrics
The view layer also scopes results by tenant when request.tenant is available, or by user when the caller is not staff.
Behavior notes
- The reporting window is controlled by
?days=Nand clamped to a safe range. - Each chart-style endpoint is independent so one failing aggregate does not have to break the whole dashboard.
- Summary numbers are computed from live database rows rather than cached snapshots.
When to change this page’s source code
Change the analytics views if you need:
- a new dashboard metric
- a different time-window filter
- a tenant scoping fix
- a new model or document-type breakdown
If you are changing payment or billing summaries, use Billing instead; some of the same underlying records may be involved but the user-facing contract is different.
Validation
- analytics-focused unit tests in
tests/unitif present - dashboard integration coverage under
tests/integration
Scope boundary
This page is only for dashboard aggregates. It is not the source of truth for activity logs or document lifecycle state.