From 7cf1ae51aa67ca17fed9d176cf4e2a0904197126 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 09:53:23 +0000 Subject: [PATCH] Document GET /distance_travelled Distance travelled on Choice trackers (MakerbleDev/makerble#17982): the openapi.yaml path and schemas, and the endpoint card. CP-8547 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xpqrMhqdcgT4e1GHkq --- openapi.yaml | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 12 ++++ 2 files changed, 185 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index 026e61a..b667307 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3879,6 +3879,74 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /distance_travelled: + get: + tags: [Projects] + summary: Get distance travelled on Choice trackers + description: | + For each **Choice tracker** (Indicator of Scale type) that has a **success direction**, how many Contacts + improved, stayed the same or worsened between their first and latest answer. These are the figures in a + Progress Board's **Success Direction Summary**, and the same rules the **distance travelled** Contact Filter + uses. Use them for change-over-time evidence such as "68% of young people reported improved confidence". + Covers the Projects you can view (Editor, Reporter or Observer of the Project or its Organisation). + + Answers are ordered by their Story's date, one answer per Story per Contact, and answers saved with no + Contact tagged are left out. Contacts with only one answer in the period are **not judged**: they are + counted in `not_judged`, and every `percent` is of `judged_contacts` only. `contacts_answered` is everyone + who answered at least once. `success_direction_meaning` says which answer is the best. `answers` is a + before/after table: for each answer, how many judged Contacts gave it first and how many gave it last. + + Choice trackers with no success direction are left out; when you choose them with `tracker_ids`, + `skipped_trackers` says which. `last_synced_datetime` doesn't apply, as the figures are totals. + operationId: getDistanceTravelled + security: [{tokenAuth: []}] + parameters: + - $ref: '#/components/parameters/Page' + - $ref: '#/components/parameters/PerPage' + - name: project_ids + in: query + schema: + type: array + items: + type: integer + style: form + explode: true + example: [619, 620] + description: Projects to include, as project_ids[]=619&project_ids[]=620 or a JSON array string ("[619,620]"). Defaults to every Project you can view; Projects you can't view are left out. + - name: tracker_ids + in: query + schema: + type: array + items: + type: integer + example: [362] + description: Choice trackers (Indicator IDs) to include, as an array or a comma-separated list. Defaults to every Choice tracker with a success direction used on the Projects. + - name: start_date + in: query + schema: + type: string + format: date + example: "2026-04-01" + description: First Story date to include (YYYY-MM-DD). Omit start_date and end_date for all time. + - name: end_date + in: query + schema: + type: string + format: date + example: "2027-03-31" + description: Last Story date to include (YYYY-MM-DD) + responses: + "200": + description: One page of Choice trackers + content: + application/json: + schema: + $ref: '#/components/schemas/PaginatedDistanceTravelled' + "401": + $ref: '#/components/responses/Unauthorized' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /projects/bulk_status_change: post: tags: [Projects] @@ -21801,6 +21869,111 @@ components: items: $ref: '#/components/schemas/ProjectResultsTracker' + PaginatedDistanceTravelled: + allOf: + - $ref: '#/components/schemas/PaginationEnvelope' + - type: object + properties: + start_date: + type: string + format: date + nullable: true + example: "2026-04-01" + end_date: + type: string + format: date + nullable: true + example: "2027-03-31" + project_ids: + type: array + items: + type: integer + example: [619] + data: + type: array + items: + $ref: '#/components/schemas/DistanceTravelledTracker' + skipped_trackers: + type: array + description: Only when tracker_ids is given. Chosen Choice trackers left out because they have no success direction. + items: + type: object + properties: + tracker_id: + type: integer + example: 363 + tracker_name: + type: string + example: Attended with a carer + reason: + type: string + example: No success direction is set, so there is no better or worse answer + + DistanceTravelledTracker: + type: object + description: Distance travelled on one Choice tracker. + properties: + tracker_id: + type: integer + description: The Indicator ID + example: 362 + tracker_name: + type: string + example: Confidence + success_direction: + type: string + enum: [bottom to top, top to bottom] + example: bottom to top + success_direction_meaning: + type: string + nullable: true + example: The last answer (Very confident) is the best + contacts_answered: + type: integer + description: Contacts who answered at least once in the period + example: 27 + judged_contacts: + type: integer + description: Contacts with two or more answers in the period + example: 18 + not_judged: + type: integer + description: Contacts with only one answer in the period + example: 9 + improved: + $ref: '#/components/schemas/DistanceTravelledShare' + no_change: + $ref: '#/components/schemas/DistanceTravelledShare' + worsened: + $ref: '#/components/schemas/DistanceTravelledShare' + answers: + type: array + description: For each answer (Sub Ratio), in the tracker's order, how many judged Contacts gave it first and last. + items: + type: object + properties: + answer: + type: string + example: Very confident + first: + type: integer + example: 2 + latest: + type: integer + example: 6 + + DistanceTravelledShare: + type: object + properties: + count: + type: integer + example: 2 + percent: + type: number + nullable: true + description: Percent of judged_contacts, to one decimal place. null when no Contact was judged. + example: 11.1 + ProjectResultsTracker: type: object description: One tracker on the Results Canvas. Which figures appear depends on tracker_type. diff --git a/server.js b/server.js index a479da4..18a4352 100644 --- a/server.js +++ b/server.js @@ -1347,6 +1347,18 @@ function buildDocsPage() { { code: "401", cls: "response-4xx", desc: "Not authenticated" }, { code: "422", cls: "response-4xx", desc: "Invalid project_ids, date, tracker_types, group_by, per_page or template_id" } ], "Returns the figures on each Project's Results Canvas (the Results panel on a Project page), one entry per tracker, for the Projects you can view. Activity and Engagement trackers (Changes) give times_recorded and contacts; Achievement trackers (Binary Indicators) give times_recorded and contacts_achieved; Choice trackers (Scale Indicators) give answers with a count and contacts per Sub Ratio; Numerical trackers (Value Indicators) give total and average_per_contact. times_recorded counts records, not people; contacts counts distinct Contacts tagged. anonymous_count is what was recorded with no Contact tagged. target, target_deadline and percent_of_target appear when the Project has a target.")} + ${endpointCard("GET", "/distance_travelled", "Get distance travelled on Choice trackers", true, [ + { name: "project_ids", type: "integer[]", required: false, desc: "Projects to include, as project_ids[]=619 or a JSON array string. Defaults to every Project you can view" }, + { name: "tracker_ids", type: "integer[]", required: false, desc: "Choice trackers (Indicator IDs) to include, as an array or comma-separated list. Defaults to every Choice tracker with a success direction on the Projects" }, + { name: "start_date", type: "string", required: false, desc: "First Story date to include, YYYY-MM-DD. Omit both dates for all time" }, + { name: "end_date", type: "string", required: false, desc: "Last Story date to include, YYYY-MM-DD" }, + { name: "page", type: "integer", required: false, desc: "Page number (default 1)" }, + { name: "per_page", type: "integer", required: false, desc: "Trackers per page (default 10, max 200)" } + ], [ + { code: "200", cls: "response-2xx", desc: "Paginated Choice trackers, plus start_date, end_date and project_ids (and skipped_trackers when you chose trackers with no success direction)" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "422", cls: "response-4xx", desc: "Invalid project_ids, tracker_ids, date or per_page" } + ], "For each Choice tracker (Scale Indicator) with a success direction, how many Contacts improved, stayed the same (no_change) or worsened between their first and latest answer: the figures in a Progress Board's Success Direction Summary. Contacts with only one answer in the period aren't judged; they are counted in not_judged, and each percent is of judged_contacts only. answers is a before/after table of first and latest answers. Answers with no Contact tagged are left out.")}