Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>times_recorded</code> and <code>contacts</code>; Achievement trackers (Binary Indicators) give <code>times_recorded</code> and <code>contacts_achieved</code>; Choice trackers (Scale Indicators) give <code>answers</code> with a count and contacts per Sub Ratio; Numerical trackers (Value Indicators) give <code>total</code> and <code>average_per_contact</code>. <code>times_recorded</code> counts records, not people; <code>contacts</code> counts distinct Contacts tagged. <code>anonymous_count</code> is what was recorded with no Contact tagged. <code>target</code>, <code>target_deadline</code> and <code>percent_of_target</code> 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 <code>project_ids[]=619</code> 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 <code>improved</code>, stayed the same (<code>no_change</code>) or <code>worsened</code> 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 <code>not_judged</code>, and each <code>percent</code> is of <code>judged_contacts</code> only. <code>answers</code> is a before/after table of first and latest answers. Answers with no Contact tagged are left out.")}
</div>
</section>

Expand Down
Loading