Please update the job to not execute the GET request on L10 if no cases are returned from the parent run of f2-1.getCasesFromPrimero.js.
Check if caseid.length = 0 --> if true, do NOT send the GET request. If caseid.length > 0 then proceed with the get request.
To Reproduce
Run the first job in the flow f2-1.getCasesFromPrimero.js... and set the manual cursor to today's day and time to create a scenario where 0 cases will be returned.
Use the output of this f2-1 job as the state.json for this next f2-2 job.
Describe the bug
The f2-2.sendReferralToDTP.js job is currently written to always send a GET request to the Primero
/users
endpoint... even if there are 0 referrals to send. If there are 0 referrals, we should take no further action and stop this job. https://github.com/OpenFn/primero-progres/blob/fb51245c6937382df6fe1d213d1eb7920fc5b9d8/jobs/PROD/f2-2.sendReferralToDTP.js#L10-L24Please update the job to not execute the GET request on L10 if no cases are returned from the parent run of f2-1.getCasesFromPrimero.js.
Check if
caseid.length = 0
--> if true, do NOT send the GET request. Ifcaseid.length > 0
then proceed with the get request.To Reproduce
f2-1
job as the state.json for this nextf2-2
job.expression.js
Link to the job itself in Github: https://github.com/OpenFn/primero-progres/blob/master/jobs/PROD/f2-2.sendReferralToDTP.js
🚨 Please make changes on a separate branch and do not commit to master until approved. 🚨
state.json
f2-j1
f2-j2
Expected behavior
If the initial state of f2-j2 is no cases, we should not be attempting to send a GET request to Primero, and should stop running.
To test/resolve