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
232 changes: 231 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13396,6 +13396,102 @@ paths:
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'
/reports/{report_id}/contents/{question_id}/refresh_data:
post:
tags: [Reports]
summary: Fill or refresh a Makerble data block
operationId: refreshReportContentData
description: |
**Fill from data** / **Refresh from data** on Write the Content. The figures are taken in the
background from the Report's timeframe, projects and albums, and Exclusive Focus, and stay
frozen until refreshed again. Answers 202 with `data_status` queued; read the answer again
until it is `filled` (or `failed`, with `data_block.error`). `metrics` chooses this Report's
own metrics, for a template whose metrics the organisation doesn't have; the template is
unchanged. Requires a Report Editor, a Report Reporter or an Organisation Admin.
security: [{tokenAuth: []}]
parameters:
- name: report_id
in: path
required: true
schema:
type: integer
example: 15
- name: question_id
in: path
required: true
schema:
type: integer
example: 31
description: A question of the Report's template with a Makerble data block
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
metrics:
type: array
items:
type: string
example:
metrics: ["Change:12", "CohortTracker:4"]
responses:
"202":
description: The fill is queued
content:
application/json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/ReportContent'
"401":
$ref: '#/components/responses/Unauthorized'
"403":
$ref: '#/components/responses/Forbidden'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'
/report_data_presets:
get:
tags: [Reports]
summary: List the Makerble data block presets
operationId: listReportDataPresets
description: |
What a Makerble data block in a Report Template can show: Target vs actual, Key figures,
Contact breakdown, Distance travelled, and Sessions and attendance. Each preset has its
settings, the displays it allows, an "answers questions like" description and its answer
shapes, so a requirement can be matched to the preset that answers it. `answer_shapes` lists
every shape.
security: [{tokenAuth: []}]
responses:
"200":
description: The presets
content:
application/json:
schema:
type: object
properties:
page:
type: integer
page_size:
type: integer
page_count:
type: integer
total_count:
type: integer
answer_shapes:
type: array
items:
$ref: '#/components/schemas/AnswerShape'
data:
type: array
items:
$ref: '#/components/schemas/DataBlockPreset'
"401":
$ref: '#/components/responses/Unauthorized'
/explore/forms:
get:
tags: [Explore]
Expand Down Expand Up @@ -26284,6 +26380,108 @@ components:
type: array
items:
type: string
makerble_data:
$ref: '#/components/schemas/DataBlockSettings'
DataBlockSettings:
type: object
description: |
A Makerble data block: figures each Report fills from its own data (its timeframe,
projects and albums, and Exclusive Focus). Only the chosen preset's settings are kept.
See GET /report_data_presets for each preset's settings and answer shapes.
required: [preset]
properties:
preset:
type: string
enum: [target_vs_actual, key_figures, contact_breakdown, distance_travelled, sessions_and_attendance]
display:
type: string
enum: [table, bar_chart, pie_chart, line_chart, figures]
description: One the preset allows; defaults to its first
metrics:
type: array
description: |
Target vs actual (1 to 20) and Key figures (1 to 6). Each is "Type:id" or {type, id},
with type Change, Indicator, CohortTracker, WorkflowTracker, FilteredMetric or
FormulaTracker. Saved with each metric's name. For a group of people, choose a filtered
version or a Cohort Tracker with that filter.
items:
oneOf:
- type: string
example: "Change:12"
- type: object
properties:
type:
type: string
id:
type: integer
name:
type: string
thresholds:
type: object
description: Target vs actual's status thresholds, as % of target
properties:
on_track:
type: integer
default: 100
close:
type: integer
default: 75
breakdown_by:
type: string
description: Contact breakdown; "age_band" or a Bio form Dropdown field's ID
second_breakdown_by:
type: string
description: Contact breakdown; an optional second field
tracker_id:
type: integer
description: Distance travelled; a Choice metric with a success direction
group_by:
type: string
enum: [total, month]
description: Sessions and attendance
DataBlockPreset:
type: object
properties:
key:
type: string
name:
type: string
answers_questions_like:
type: string
answer_shapes:
type: array
items:
$ref: '#/components/schemas/AnswerShape'
displays:
type: array
items:
type: string
settings:
type: array
items:
type: object
properties:
key:
type: string
label:
type: string
type:
type: string
min:
type: integer
max:
type: integer
required:
type: boolean
options:
type: array
items:
type: string
default: {}
AnswerShape:
type: string
description: The kind of answer a requirement asks for and a preset or metric gives
enum: [count, sum, average, ratio, share_meeting_threshold, change_over_time, breakdown, quote]
ReportTemplateQuestion:
type: object
properties:
Expand All @@ -26303,7 +26501,7 @@ components:
type: array
items:
type: string
enum: [narrative, number, chart, table]
enum: [narrative, number, chart, table, makerble_data]
output_settings:
$ref: '#/components/schemas/ReportOutputSettings'
ReportTemplate:
Expand Down Expand Up @@ -26446,6 +26644,38 @@ components:
type: string
format: date-time
nullable: true
data_status:
type: string
enum: [empty, queued, filling, filled, failed]
description: Only for a question with a Makerble data block
data_block:
type: object
nullable: true
description: |
The block's figures, frozen as they were taken until it is refreshed: columns
({key, label, type: text|number|percent|status}), rows, notes, missing_metrics and, for a
chart display, chart ({type, labels, series}); or error when it couldn't fill. A figure about
fewer than 5 Contacts is "<5".
data_taken_at:
type: string
format: date-time
nullable: true
data_scope:
type: object
nullable: true
description: The project_ids, bundle_ids, from, to and exclusive_focus the figures were taken at
data_scope_changed:
type: boolean
description: True when the Report's scope has changed since the figures were taken
data_settings:
type: object
nullable: true
description: This Report's own metrics, chosen when the template's aren't the organisation's
written_against_data_at:
type: string
format: date-time
nullable: true
description: When the Report's data blocks were last filled before the Narrative was written
PaginatedReportContents:
type: object
properties:
Expand Down
17 changes: 16 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3253,8 +3253,9 @@ function buildDocsPage() {
<div class="section-eyebrow">Reporting</div>
<h2 class="section-title">Report Templates</h2>
<div class="section-desc">
<p>A Report Template is the list of questions a report has to answer, for Makerble&reg; ReportMaker&trade;. Each question says what kind of answer it needs in <code>expected_output_types</code>: any of <code>narrative</code>, <code>number</code>, <code>chart</code> and <code>table</code>.</p>
<p>A Report Template is the list of questions a report has to answer, for Makerble&reg; ReportMaker&trade;. Each question says what kind of answer it needs in <code>expected_output_types</code>: any of <code>narrative</code>, <code>number</code>, <code>chart</code>, <code>table</code> and <code>makerble_data</code>.</p>
<p><code>output_settings</code> holds each output's settings: <code>word_limit</code> for a Narrative the recipient limits (e.g. "max 250 words"), and for a Table, <code>table</code> with <code>columns</code> (each a <code>heading</code> and a <code>type</code> of <code>text</code> or <code>number</code>), <code>row_mode</code> (<code>reporter_adds</code> or <code>fixed</code>) and, for fixed rows, <code>fixed_row_labels</code>. With fixed rows the first column holds the labels.</p>
<p><code>makerble_data</code> is a <strong>Makerble data block</strong>: figures each Report fills from its own data (its timeframe, projects and albums, and Exclusive Focus) instead of someone typing them in. Its settings are <code>output_settings.makerble_data</code>: a <code>preset</code> (<code>target_vs_actual</code>, <code>key_figures</code>, <code>contact_breakdown</code>, <code>distance_travelled</code> or <code>sessions_and_attendance</code>), a <code>display</code>, and the preset's own settings, e.g. <code>{"preset": "target_vs_actual", "display": "table", "metrics": ["Change:12", "CohortTracker:4"]}</code>. List the presets, their settings and their answer shapes with <code>GET /report_data_presets</code>. For a group of people, such as young women in work, choose a filtered version or a Cohort Tracker with that filter: a Report's Exclusive Focus can't give Cohort, Workflow or Formula Tracker figures.</p>
</div>
<div class="endpoint-list">
${endpointCard("GET", "/report_templates", "List an organisation's Report Templates", true, [
Expand Down Expand Up @@ -3294,6 +3295,9 @@ function buildDocsPage() {
{ code: "404", cls: "response-4xx", desc: "Not found, or one you can't see" },
{ code: "422", cls: "response-4xx", desc: "<code>errors</code>" }
], "Fields left out stay as they are.")}
${endpointCard("GET", "/report_data_presets", "List the Makerble data block presets", true, [], [
{ code: "200", cls: "response-2xx", desc: "Each preset's <code>key</code>, <code>name</code>, <code>answers_questions_like</code>, <code>answer_shapes</code>, <code>displays</code> and <code>settings</code>, and <code>answer_shapes</code>: every shape (<code>count</code>, <code>sum</code>, <code>average</code>, <code>ratio</code>, <code>share_meeting_threshold</code>, <code>change_over_time</code>, <code>breakdown</code>, <code>quote</code>). Match a requirement's shape to a preset, then use the description to choose between presets that match" }
])}
</div>
</section>

Expand All @@ -3303,6 +3307,7 @@ function buildDocsPage() {
<h2 class="section-title">Report answers</h2>
<div class="section-desc">
<p>A Report's answers (Report Contents), one per question of its Report Template, as Write the Content shows them. A Table answer is <code>table_rows</code>: one array of cells per row, in the order of the template's columns.</p>
<p>A question with a Makerble data block also has <code>data_status</code> (<code>empty</code>, <code>queued</code>, <code>filling</code>, <code>filled</code> or <code>failed</code>), <code>data_block</code> (its figures, frozen as they were taken until it is refreshed: <code>columns</code>, <code>rows</code>, <code>notes</code>, <code>missing_metrics</code> and, for a chart, <code>chart</code>; or <code>error</code>), <code>data_taken_at</code>, <code>data_scope</code>, <code>data_scope_changed</code>, <code>data_settings</code> (this Report's own metrics) and <code>written_against_data_at</code>. A figure about fewer than 5 Contacts is <code>"&lt;5"</code>.</p>
</div>
<div class="endpoint-list">
${endpointCard("GET", "/reports/{report_id}/contents", "List a Report's answers", true, [
Expand Down Expand Up @@ -3332,6 +3337,16 @@ function buildDocsPage() {
{ code: "404", cls: "response-4xx", desc: "A Report you can't see, or a question from another template" },
{ code: "422", cls: "response-4xx", desc: "<code>errors</code>, e.g. <code>Row 1: Target must be a number</code>" }
])}
${endpointCard("POST", "/reports/{report_id}/contents/{question_id}/refresh_data", "Fill or refresh a Makerble data block", true, [
{ name: "report_id", in: "path", type: "integer", required: true, desc: "The Report" },
{ name: "question_id", in: "path", type: "integer", required: true, desc: "A question of the Report's template with a Makerble data block" },
{ name: "metrics", in: "body", type: "array", required: false, desc: "This Report's own metrics, e.g. <code>[\"Change:12\"]</code>, when its template's aren't the organisation's (<code>data_block.missing_metrics</code>). The template is unchanged" }
], [
{ code: "202", cls: "response-2xx", desc: "The fill is queued: the answer, in <code>data</code>, with <code>data_status</code> <code>queued</code>. Read it again until it is <code>filled</code>" },
{ code: "403", cls: "response-4xx", desc: "Not a Report Editor, Report Reporter or Organisation Admin" },
{ code: "404", cls: "response-4xx", desc: "A Report you can't see, or a question from another template" },
{ code: "422", cls: "response-4xx", desc: "A question with no Makerble data block, or <code>metrics</code> that name none" }
], "Fill from data / Refresh from data on Write the Content. The figures are taken in the background and stay frozen until refreshed again.")}
</div>
</section>

Expand Down
Loading