Per-activity + needs-review counts for the journal chip row
const url = 'http://localhost:8000/api/sessions/counts/';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url http://localhost:8000/api/sessions/counts/ \ --header 'Authorization: Bearer <token>'Returns the activity-chip counts shown on the sessions journal — per-activity totals plus the count of completed sessions awaiting coach review. With server-side pagination on GET /api/sessions/ (#364), the FE no longer holds the full dataset client-side and needs a dedicated cheap aggregate endpoint for chip badges. Two GROUP BY-style queries against the existing (activity, status) composite index — fast even on a clinic-scale team.
Filters mirror the list endpoint for the same axes (from/to/client/is_demo) so a coach narrowing the date window sees chip counts that match what’s in the list. DELIBERATELY ignored: activity (the dimension being counted; chip toggle would zero its own count), exercise, camera_view, search, sort, needs_review (a separate aggregate is returned). “What will I see if I click this chip?” — the chip toggles only the activity axis; everything else stays.
Auth: team-scoped — reachable with a partner aik_… API key as well as a user session.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”UUID of a Client to scope the counts to.
Range start (ISO YYYY-MM-DD, inclusive). Combined at the viewer’s tz start-of-day so the count window matches the coach’s calendar day, not the server’s UTC day (#707). Pairs with to.
When true, counts the curated demo team’s sessions instead of the caller’s team.
Range end (ISO YYYY-MM-DD, inclusive). Combined at the viewer’s tz end-of-day. Pairs with from.
Viewer’s IANA timezone (e.g. America/Chicago) used to combine from/to into local-day boundaries. Omit to fall back to UTC (legacy / partner-key callers).
Responses
Section titled “Responses”object
Per-activity session count within the current from/to/client scope. Every member of the Activity enum is included — absent activities carry 0 so the FE chip row can render without a missing-key branch.
object
Completed sessions in the same scope that do not yet have a coach_review metric. Drives the ‘Needs review (N)’ header badge on the journal.
Sessions still in the pipeline (pending + processing) in the same scope. One of the three inputs to the global notifications-bell badge.
Sessions whose pipeline ended in failed in the same scope. One of the three inputs to the global notifications-bell badge.
Examplegenerated
{ "activity_counts": { "additionalProperty": 1 }, "needs_review_count": 1, "processing_count": 1, "failed_count": 1}object
Human-readable message, or a stable machine code for the cases a client branches on. The standard envelope for 400 (validation — a field-keyed object may appear instead), 401 (missing / invalid credentials), 403 (authenticated but not permitted), and 404 (absent — cross-team records are collapsed to 404 so the API never leaks the existence of another team’s data).
Examplegenerated
{ "detail": "example"}object
Human-readable message, or a stable machine code for the cases a client branches on. The standard envelope for 400 (validation — a field-keyed object may appear instead), 401 (missing / invalid credentials), 403 (authenticated but not permitted), and 404 (absent — cross-team records are collapsed to 404 so the API never leaks the existence of another team’s data).
Examplegenerated
{ "detail": "example"}