OpenFn / unicef-cambodia

UNICEF Cambodia - Primero Interoperability
https://openfn.github.io/unicef-cambodia/
1 stars 2 forks source link

getCases: TypeError after upgrading adaptor version #78

Closed daissatou2 closed 3 years ago

daissatou2 commented 3 years ago

Describe the bug

We upgraded the adaptor version for this old job. We are running into this error, can you help us clean up the job?

state

NA See LP Primero V2 Cambodia Demo API user

To Reproduce

  1. Here is a link to a failed run on OpenFn.org which is indicative of the bug: https://www.openfn.org/projects/p56pbe/runs/0618a529-b7f4-7282-87b2-9fff4d22df28

expression.js

PLEASE MAKE SURE TO ONLY EDIT THE JOBS IN THE V2 DIRECTORY... the others in the main directory are live on prod. https://www.openfn.org/projects/p56pbe/jobs/jywaga https://github.com/OpenFn/unicef-cambodia/blob/master/jobs/V2/f1-j1-getPrimeroCases.js

To test/resolve

Feel free to re-run this run on prod to retrigger the flow: https://www.openfn.org/projects/p56pbe/runs/0618a529-b7f4-7282-87b2-9fff4d22df28

aleksa-krolls commented 3 years ago

@lakhassane pls prioritize this morning and let @daissatou2 know when finished. Note: PLEASE MAKE SURE TO ONLY EDIT THE JOBS IN THE V2 DIRECTORY... the others in the main directory are live on prod. https://github.com/OpenFn/unicef-cambodia/blob/master/jobs/V2/f1-j1-getPrimeroCases.js

@daissatou2 pls make sure these GH files are linked to the jobs in the OpenFn Staging project.

RE: the issue... it looks like before we used transitions_created_at as the date cursor, but this is no longer in the JSON response received from Primero: https://github.com/OpenFn/unicef-cambodia/blob/master/sample_data/primeroV2_getCases.json

Therefore I think we should change the cursor date time to use case last_updated_at. See the progres project for how we did this: https://github.com/OpenFn/primero-progres/blob/master/jobs/2.a.getCases.js#L24

Hopefully this should help us get cases & services referred to oscar to then send to the next job f1-j2.

lakhassane commented 3 years ago

@aleksa-krolls I have questions in here. Do you know what was the reason for doing this: https://github.com/OpenFn/unicef-cambodia/blob/master/jobs/V2/f1-j1-getPrimeroCases.js#L3-L21

Because without a message this job cannot work (because state.data does not exist). Could you clarify what was the intention so I can know how to clean?

lakhassane commented 3 years ago

@daissatou2 here is the last run: https://www.openfn.org/projects/p56pbe/runs/0618ba8a-8315-7c4e-8a25-612e054743f8. Corrected how we handle the different cursor and the date parsing.

As discussed with Aïcha, we might not need to keep a manualCursor since they are directly specified in the filtering option for the getCase()