Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kobotoolbox: add job examples #633

Merged
merged 8 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions adaptors/library/jobs/kobotoolbox-get-submissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn(state => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the value of the fn() block in this example?

state.formId = state.data.formId;
return state;
});

getSubmissions($.formId);
13 changes: 13 additions & 0 deletions adaptors/library/jobs/kobotoolbox-get-suspected-patients.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Get all submissions of a specific form/asset and get the percentage of patients suspected of having covid-19
http.get('/assets/aDReHdA7UuNBYsiCXQBr43/data/');

fn(state => {
const results = state.data?.results;

const suspectedPatients = results.filter(
item => item['Please_select_sample_type'] === 'suspected_covid_19'
);
const suspectedCovidPatientsPercentage =
(suspectedPatients.length / results.length) * 100;
return { ...state, suspectedCovidPatientsPercentage };
});
10 changes: 10 additions & 0 deletions adaptors/library/staticExamples.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,15 @@
"expressionPath": "jobs/async-findValue",
"adaptor": "postgresql",
"name": "Using findValue with an array of data"
},
{
"expressionPath": "jobs/kobotoolbox-create-asset",
"adaptor": "kobotoolbox",
"name": "Create an asset in KoboToolbox"
},
{
"expressionPath": "jobs/kobotoolbox-get-submissions",
"adaptor": "kobotoolbox",
"name": "Extract submissions from KoboToolbox"
}
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
"cytoscape": "3.28.1"
},
"packageManager": "[email protected]"
}
}
Loading