Skip to content

Add paging to f1-j1-getPrimeroCasesV2.js #130

@aleksa-krolls

Description

@aleksa-krolls

Request

Primero API requests are now limited to a maximum of 1,000 records. While it's rare that we an API query returns more than 1,000 records, we should proactively update our OpenFn jobs to consider this limit and to handle paging if more than 1k records do exist.

In the job V2/f1-j1-getPrimeroCasesV2.js, we need to (1) change the parameter per to one thousand per: 1000 and then (2) handle scenarios where multiple pages of data may be returned

expression.js

Please branch off main and update the job V2/f1-j1-getPrimeroCasesV2.js . MAKE SURE TO ONLY UPDATE JOB IN V2 FOLDER:
https://github.com/OpenFn/unicef-cambodia/blob/master/jobs/V2/f1-j1-getPrimeroCasesV2.js

Query to update:

getCases(
{
remote: true,
last_updated_at: state => `${state.cursor}..`,
//last_updated_at: '2023-08-24T00:00:00.862Z..', //for troubleshooting
//last_updated_at: state => `${state.cursor}..2023-08-14T15:00:00.862Z`, //for troubleshooting
page: 1,
per: 10000,
// These cases have been recently updated and MIGHT have a new referral to send to Oscar; we check & filter below
// workflow: 'referral_to_oscar', //REMOVED July '23 bc we should rely on services, not case-level statuses
},

state

Primero (to generate state):

{
"configuration": "Primero V2 Cambodia Demo API user",
"data": {}
}

To test

Feel free to run locally. When ready to test, pls merge to the staging branch so that we can test on the Staging platform project: https://www.openfn.org/projects/primero-oscar-cambodia-io-staging/jobs/jywaga

Toggl

UNICEF Cambodia Primero IO Support [2024]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions