diff --git a/openapi.yaml b/openapi.yaml index b4e0663..a05534d 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -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] @@ -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: @@ -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: @@ -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: diff --git a/server.js b/server.js index 96f5fb8..af3d0dc 100644 --- a/server.js +++ b/server.js @@ -3253,8 +3253,9 @@ function buildDocsPage() {
A Report Template is the list of questions a report has to answer, for Makerble® ReportMaker™. Each question says what kind of answer it needs in expected_output_types: any of narrative, number, chart and table.
A Report Template is the list of questions a report has to answer, for Makerble® ReportMaker™. Each question says what kind of answer it needs in expected_output_types: any of narrative, number, chart, table and makerble_data.
output_settings holds each output's settings: word_limit for a Narrative the recipient limits (e.g. "max 250 words"), and for a Table, table with columns (each a heading and a type of text or number), row_mode (reporter_adds or fixed) and, for fixed rows, fixed_row_labels. With fixed rows the first column holds the labels.
makerble_data is a Makerble data block: 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 output_settings.makerble_data: a preset (target_vs_actual, key_figures, contact_breakdown, distance_travelled or sessions_and_attendance), a display, and the preset's own settings, e.g. {"preset": "target_vs_actual", "display": "table", "metrics": ["Change:12", "CohortTracker:4"]}. List the presets, their settings and their answer shapes with GET /report_data_presets. 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.
errors" }
], "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 key, name, answers_questions_like, answer_shapes, displays and settings, and answer_shapes: every shape (count, sum, average, ratio, share_meeting_threshold, change_over_time, breakdown, quote). Match a requirement's shape to a preset, then use the description to choose between presets that match" }
+ ])}
A Report's answers (Report Contents), one per question of its Report Template, as Write the Content shows them. A Table answer is table_rows: one array of cells per row, in the order of the template's columns.
A question with a Makerble data block also has data_status (empty, queued, filling, filled or failed), data_block (its figures, frozen as they were taken until it is refreshed: columns, rows, notes, missing_metrics and, for a chart, chart; or error), data_taken_at, data_scope, data_scope_changed, data_settings (this Report's own metrics) and written_against_data_at. A figure about fewer than 5 Contacts is "<5".
errors, e.g. Row 1: Target must be a number" }
])}
+ ${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. [\"Change:12\"], when its template's aren't the organisation's (data_block.missing_metrics). The template is unchanged" }
+ ], [
+ { code: "202", cls: "response-2xx", desc: "The fill is queued: the answer, in data, with data_status queued. Read it again until it is filled" },
+ { 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 metrics 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.")}