OpenFn / ConSoSci

ConSoSci jobs to integrate: BNS and NRGT Kobo Toolbox forms and other WCS/Partner Kobo form integrations.
https://openfn.github.io/ConSoSci/
4 stars 3 forks source link

Add `DatasetOwner` and `DatasetName` to `getFormDataFromKobo.js` #193

Closed taylordowns2000 closed 1 year ago

taylordowns2000 commented 1 year ago

We'd like to add 2 new fields to the mapping for the Trillion Trees project:

Mappings for these fields can be found here

expression.js

⚠️ Please create a Staging branch and make all changes on this branch; do NOT commit to Master. Link to the job itself in Github: KM2. Fetch Kobo Forms Data job

state.json

Run the the KM1. Get List of Kobo Forms job using the details below. This will trigger the KM2. Fetch Kobo Forms Data job

MSSQL DB See LP for WCS test mssql db Once logged into the wcsprograms_opiant DB, select the dbo schema and find the table called TT_KOBODATA.

Note: You will require OpenFn VPN / Wireguard to connect to the DB.

KOBO TOOLBOX See LP for Trillion Trees Kobo (TT) Here is a sample json from Kobo that serves as input to Job 2

{
  "configuration": ["SEE LAST PASS: 'client cred'"],
  "data": { "a": 1 },
  "cursor": "2020-01-19 00:00:00"
}

Expected behavior

Data should be fetched from Kobo and used to trigger the sync Job (KM 3) to upsert data in the DB.

To test/resolve

  1. After the desired output is working locally (from the CLI), please [push commits to staging branch || open a pull request].
  2. @jayesse will test on platform to confirm that the job is now able to fetch the right data from Kobo

Toggl

WCS Support 2023

mtuchi commented 1 year ago

@jayesse I have added the DatasetOwner and DatasetName in the mapping for both Trillion Trees and WCS projects

Let me know once you have a way forward for Last submission time

jayesse commented 1 year ago

@mtuchi The client chose the option of ignoring (not syncing) the last submission time field for now and would only consider the date_created, date_modified fields for their analysis. Hence, I have updated the issue to reflect this.

Can you confirm that the current API V2 asset endpoint we're using has all the information we need to map all the fields in the Mapping Sheet?

jayesse commented 1 year ago

@Mtuchi I'm testing WCS Trillion Trees Kobo Monitoring implementation, and I encountered this error when running the KM2. Fetch Kobo Forms Data job:

TypeError [Error]: Cannot read properties of undefined (reading 'data')
    at vm.js:80:34
    at VM2 Wrapper.apply (/home/app/assets/node_modules/vm2/lib/bridge.js:485:11)

See run log here: https://openfn.org/projects/trillion-trees/runs/063bff6d-d180-7473-95e9-47ca7d27e589

jayesse commented 1 year ago

@mtuchi Thanks for your troubleshooting. My tests are now successful and these new fields are correctly synced with the DB. I will ask the client to test and confirm. I will close this issue now.