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
165 changes: 163 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4354,11 +4354,28 @@ paths:
`default_results_template_id` on `GET /projects/{id}`. Omit for every tracker.
responses:
"200":
description: One page of trackers
description: One page of trackers, plus label_results
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedProjectResults'
allOf:
- $ref: '#/components/schemas/PaginatedProjectResults'
- type: object
properties:
label_results:
type: array
description: |
Each Label (Story Label) that evidences one of the Projects' Outcomes, with the Stories and survey
responses carrying it dated in the timeframe, and its deadline targets dated in it. Not paginated.
items:
type: object
properties:
label_id: { type: integer }
label_name: { type: string }
outcome_id: { type: integer }
outcome_name: { type: string }
story_count: { type: integer }
target: { type: integer, nullable: true }
"401":
$ref: '#/components/responses/Unauthorized'
"422":
Expand Down Expand Up @@ -7009,6 +7026,124 @@ paths:
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'
/labels/{label_id}/outcomes:
parameters:
- name: label_id
in: path
required: true
schema: { type: integer }
get:
tags: [Labels]
summary: List the Outcomes a Label evidences
description: |
Stories and survey responses with a Label show under the Outcomes it evidences on a Project's Results Canvas.
`editable` is false for an Outcome you can't edit, whose link you can't remove.
operationId: listLabelOutcomes
security: [{tokenAuth: []}]
parameters:
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PerPage'
responses:
"200":
description: The linked Outcomes
content:
application/json:
schema: { $ref: '#/components/schemas/LabelOutcomesPage' }
"401":
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'
put:
tags: [Labels]
summary: Set the Outcomes a Label evidences
description: |
`outcome_ids` replaces the links you may change. Links to Outcomes you can't edit are kept. You can only link
Outcomes you can edit. Linking from the Outcome side edits the same links.
operationId: setLabelOutcomes
security: [{tokenAuth: []}]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [outcome_ids]
properties:
outcome_ids: { type: array, items: { type: integer } }
example:
outcome_ids: [5120, 5121]
responses:
"200":
description: The linked Outcomes
content:
application/json:
schema: { $ref: '#/components/schemas/LabelOutcomesPage' }
"401":
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntityList'
/outcomes/{outcome_id}/labels:
parameters:
- name: outcome_id
in: path
required: true
schema: { type: integer }
get:
tags: [Labels]
summary: List the Labels that evidence an Outcome
description: |
Your organisations' Labels linked to the Outcome. Other organisations' Labels are counted in `other_label_count`.
`editable` says whether you may change the Outcome's Labels.
operationId: listOutcomeLabels
security: [{tokenAuth: []}]
parameters:
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PerPage'
responses:
"200":
description: The linked Labels
content:
application/json:
schema: { $ref: '#/components/schemas/OutcomeLabelsPage' }
"401":
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'
put:
tags: [Labels]
summary: Set the Labels that evidence an Outcome
description: |
`label_ids` replaces your organisations' Labels on the Outcome; other organisations' are kept. You must be able
to edit the Outcome.
operationId: setOutcomeLabels
security: [{tokenAuth: []}]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [label_ids]
properties:
label_ids: { type: array, items: { type: integer } }
example:
label_ids: [412]
responses:
"200":
description: The linked Labels
content:
application/json:
schema: { $ref: '#/components/schemas/OutcomeLabelsPage' }
"401":
$ref: '#/components/responses/Unauthorized'
"403":
$ref: '#/components/responses/ForbiddenError'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntityList'
/stories/{story_id}/labels:
parameters:
- name: story_id
Expand Down Expand Up @@ -28292,6 +28427,32 @@ components:
name: { type: string, maxLength: 255 }
color: { type: string, pattern: '^#[0-9a-fA-F]{6}$', description: 'Default #3595d5' }
privacy: { type: string, enum: [only_charity_colleagues, everyone], description: Default only_charity_colleagues }
LabelOutcomesPage:
allOf:
- $ref: '#/components/schemas/PaginationEnvelope'
- type: object
properties:
label_id: { type: integer }
data:
type: array
items:
type: object
properties:
id: { type: integer }
title: { type: string }
project_count: { type: integer, description: How many projects use the Outcome }
editable: { type: boolean, description: Whether you may remove this link }
OutcomeLabelsPage:
allOf:
- $ref: '#/components/schemas/PaginationEnvelope'
- type: object
properties:
outcome_id: { type: integer }
editable: { type: boolean }
other_label_count: { type: integer }
data:
type: array
items: { $ref: '#/components/schemas/Label' }
StoryLabelsResult:
type: object
properties:
Expand Down
35 changes: 34 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ function buildDocsPage() {
{ 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 trackers, plus start_date, end_date and project_ids" },
{ code: "200", cls: "response-2xx", desc: "Paginated trackers, plus start_date, end_date, project_ids and <code>label_results</code>: each Label that evidences the Projects' Outcomes, with its <code>story_count</code> in the timeframe and <code>target</code>" },
{ 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.")}
Expand Down Expand Up @@ -2526,6 +2526,39 @@ function buildDocsPage() {
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not one of your organisations' Labels" }
], "The Stories and survey responses with this Label that you can see: ids and dates only. Fetch one with <code>GET /stories/{id}</code>.")}
${endpointCard("GET", "/labels/{label_id}/outcomes", "List the Outcomes a Label evidences", true, [
{ name: "label_id", in: "path", type: "integer", required: true, desc: "The Label" }
], [
{ code: "200", cls: "response-2xx", desc: "<code>data</code>: each Outcome's <code>id</code>, <code>title</code>, <code>project_count</code> and <code>editable</code>" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not one of your organisations' Labels" }
], "Stories with the Label show under these Outcomes on the Results Canvas. <code>editable</code> is false for an Outcome you can't edit.")}
${endpointCard("PUT", "/labels/{label_id}/outcomes", "Set the Outcomes a Label evidences", true, [
{ name: "label_id", in: "path", type: "integer", required: true, desc: "The Label" },
{ name: "outcome_ids", in: "body", type: "integer[]", required: true, desc: "Every Outcome the Label should evidence" }
], [
{ code: "200", cls: "response-2xx", desc: "The linked Outcomes" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not one of your organisations' Labels" },
{ code: "422", cls: "response-4xx", desc: "An Outcome you can't edit" }
], "Replaces the links you may change; links to Outcomes you can't edit are kept.")}
${endpointCard("GET", "/outcomes/{outcome_id}/labels", "List the Labels that evidence an Outcome", true, [
{ name: "outcome_id", in: "path", type: "integer", required: true, desc: "The Outcome" }
], [
{ code: "200", cls: "response-2xx", desc: "<code>data</code>: your organisations' Labels, plus <code>editable</code> and <code>other_label_count</code>" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "An Outcome you can't see" }
])}
${endpointCard("PUT", "/outcomes/{outcome_id}/labels", "Set the Labels that evidence an Outcome", true, [
{ name: "outcome_id", in: "path", type: "integer", required: true, desc: "The Outcome" },
{ name: "label_ids", in: "body", type: "integer[]", required: true, desc: "Every one of your Labels that should evidence it" }
], [
{ code: "200", cls: "response-2xx", desc: "The linked Labels" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "403", cls: "response-4xx", desc: "An Outcome you can't edit" },
{ code: "404", cls: "response-4xx", desc: "An Outcome you can't see" },
{ code: "422", cls: "response-4xx", desc: "A Label that isn't your organisations'" }
], "Other organisations' Labels on the Outcome are kept.")}
${endpointCard("POST", "/stories/{story_id}/labels", "Add a Label to a Story", true, [
{ name: "story_id", in: "path", type: "integer", required: true, desc: "The Story or survey response" },
{ name: "label_id", in: "body", type: "integer", required: true, desc: "The Label" }
Expand Down
Loading