diff --git a/openapi.yaml b/openapi.yaml index ad1fc2f..b3747ca 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -10114,6 +10114,21 @@ components: type: integer nullable: true description: "Cases sources only: count only the Cases created with this one of the Organisation's Case Forms" + contact_criteria: + $ref: '#/components/schemas/WorkflowTrackerContactCriteria' + + WorkflowTrackerContactCriteria: + type: object + description: >- + "Only count contacts who match": Contact Filters criteria, in the same shape as a Cohort Tracker's criteria + and a Saved Filter's, that a Contact must meet for their items to count. Matched on each Contact's current + details, so editing a Contact can change past results. {} counts every Contact. Keys a Contacts filter + doesn't read, and blank values, are dropped. + additionalProperties: true + example: + age_to: + year: "17" + beneficiary_types: ["3"] WorkflowTracker: type: object @@ -10146,6 +10161,8 @@ components: example: destinations: "except" project_ids: [4512] + contact_criteria: + $ref: '#/components/schemas/WorkflowTrackerContactCriteria' created_at: type: string format: date-time diff --git a/server.js b/server.js index ed83f16..663d943 100644 --- a/server.js +++ b/server.js @@ -2090,7 +2090,7 @@ function buildDocsPage() {
A Workflow Tracker is a metric that counts records Makerble's own features create, rather than Contacts tagged in updates. Its source says what it counts: signpostings (Signpostings made from the Project, counted once whether they name the Organisation signposted to, the Person, or both; signpostings saved without a Project aren't counted anywhere), internal_referrals (Contacts in the Project who are added to another of the Organisation's Projects, dated by the Status in Projects history), cases_created (Cases created on the Project), cases_closed (each time one of those Cases is closed) or cases_open (the Cases open at the end of each timeframe; always a snapshot). count_mode is items (each signposting, referral, Case or closing; adds up across periods, except cases_open) or contacts (each Contact once; a snapshot). Confidential Cases are counted, but only listed to people who can see them. It is placed in an Impact Scorecard column like other metrics.
A Workflow Tracker is a metric that counts records Makerble's own features create, rather than Contacts tagged in updates. Its source says what it counts: signpostings (Signpostings made from the Project, counted once whether they name the Organisation signposted to, the Person, or both; signpostings saved without a Project aren't counted anywhere), internal_referrals (Contacts in the Project who are added to another of the Organisation's Projects, dated by the Status in Projects history), cases_created (Cases created on the Project), cases_closed (each time one of those Cases is closed) or cases_open (the Cases open at the end of each timeframe; always a snapshot). count_mode is items (each signposting, referral, Case or closing; adds up across periods, except cases_open) or contacts (each Contact once; a snapshot). Confidential Cases are counted, but only listed to people who can see them. It is placed in an Impact Scorecard column like other metrics. Set contact_criteria (\"Only count contacts who match\") to count only the items of Contacts who meet Contact Filters criteria, in the same shape as a Cohort Tracker's criteria; they are matched on each Contact's current details, so editing a Contact can change past results.
results: {period, year_to_date, all_time} on the Project, and the latest records counted that the user may see, with hidden_count for the rest" },
{ code: "404", cls: "response-4xx", desc: "The Project isn't the Organisation's" },
{ code: "422", cls: "response-4xx", desc: "Unknown source or count_mode, or bad settings" }
- ], "Body: charity_id, project_id, workflow_tracker: {source, count_mode, settings}. The Period ends at the Project's next deadline, or today when it has none ahead.")}
+ ], "Body: charity_id, project_id, workflow_tracker: {source, count_mode, settings, contact_criteria}. The Period ends at the Project's next deadline, or today when it has none ahead.")}
${endpointCard("POST", "/workflow_trackers", "Create a Workflow Tracker", true, [], [
{ code: "201", cls: "response-2xx", desc: "Workflow Tracker created" },
{ code: "403", cls: "response-4xx", desc: "Not an editor or reporter of the Organisation" },
{ code: "422", cls: "response-4xx", desc: "Validation failed" }
- ], "Body: workflow_tracker: {charity_id, name, description, source, count_mode, settings}. For internal_referrals, settings choose which Projects count as a referral: {destinations: \"any\"}, {destinations: \"only\", project_ids: [...]} or {destinations: \"except\", project_ids: [...]} (the default, with none listed). For the Cases sources, settings: {case_form_id: ...} counts only the Cases created with that Case Form; leave it out for any.")}
+ ], "Body: workflow_tracker: {charity_id, name, description, source, count_mode, settings, contact_criteria}. contact_criteria (optional): Contact Filters criteria a Contact must meet for their items to count, e.g. {age_to: {year: \"17\"}}; {} counts every Contact. For internal_referrals, settings choose which Projects count as a referral: {destinations: \"any\"}, {destinations: \"only\", project_ids: [...]} or {destinations: \"except\", project_ids: [...]} (the default, with none listed). For the Cases sources, settings: {case_form_id: ...} counts only the Cases created with that Case Form; leave it out for any.")}
${endpointCard("PATCH", "/workflow_trackers/{id}", "Update a Workflow Tracker", true, [
{ name: "id", in: "path", type: "integer", required: true, desc: "Workflow Tracker ID" }
], [