Closed daissatou2 closed 2 years ago
@daissatou2 Responding to your AK please advise
requests :)
POST
). Rather, we want to define the DB operation that is best to use... so what makes sense here? create
, update
, upsert
?@daissatou2 for things like "Type of Case" = "Children Undergoing Reintegration"
, Mamadou will need the db field name and value. If this is not provided by Phanneth & Mohan in the mapping sheet, then follow up with them to get the necessary info so that you can finalize this issue spec.
@aleksa-krolls can you help me understand what should be added to the "data" and "cursor" sections here?
@aleksa-krolls this is ready for you
@daissatou2 Nearly there. Some feedback...
case_id
... bc we might need to ask them to add this too so that we can upsert. trigger
section - important to ask for "flow" jobsstate
, see how I updated your issue vs. what you had before (see screenshot)
Once feedback has been addressed, okay to move to backlog!
Hello @daissatou2 I am taking over this issue, would you mind a quick talk in implementation to make sure I understand what to do here ?
@daissatou2 can you please sync up with @elias-ba in the morning to talk this through?
@daissatou2 what's the equivalent value of type_of_placement
in the ONA Database ? The mapping excel sheet has an empty value. What should I do in that case ?
@elias-ba placement_type
has been added to the mappings.
@elias-ba we have created a separate repo for this integration: https://github.com/OpenFn/primero-ona-dashboard Please add the code for this issue to that repo. Any future issues relating to this integration will also be added to that repo.
Thanks @daissatou2. I was working in the Unicef-Cambodia repo but I will move the code to that new repo.
@daissatou2 I am done write the expressions for this issue.
I am not able to test the upsert operation locally, it seems like the ONA database is not up and running. Is there any way to test this on platform ?
@daissatou2 @aleksa-krolls do we want to keep a cursor and get newest cases or we can get all cases matching the conditions everytime.
I have tested this in my local environment and it's working fine. I am now moving it in Review. Please @daissatou2 test it on platform and let me know if there's any additional thing to do on it. Thanks
@elias-ba I believe we want to get cases where created_at
is within a certain date range... see Aicha's notes on the issue:
Example for the cursor above: If the job cron trigger runs on Jan 1, 2022, we want to GET cases that would have been created before Jan 1, 2022 but after Jan 1, 2021.
I don't see any date filter currently applied to the GET request: https://github.com/OpenFn/primero-ona-dashboard/blob/main/jobs/getCasesFromPrimero.js
cc @daissatou2
Thanks @aleksa-krolls, currently I have implemented no cursor. Is there something missing in @daissatou2's comment ? I can't understand it very well. Is there a not
or something like that missing ?
@elias-ba it means we need a date filter added like this where we only get cases if they were created after a specific date...
created_at: '2021-01-01T00:00:00.000Z'
@daissatou2 pls get on with Elias tomorrow morning to review and make sure this is working.
Thanks @aleksa-krolls this is very clear. @daissatou2 I am going to update the job expression and add that filter then tomorrow morning we can review the functionality together.
Hey @daissatou2 I have implemented a date filter on the created_at field to match cases between a starting date and an ending date. Could you check please if this is what you expected ?
@daissatou2 please don't waste your time testing this right now. @taylordowns2000 and I are working on it. We'll keep you posted.
@daissatou2 this is now done and ready for testing. Let me know for any feed-back.
Feature Request
Background, context, and business value
OpenFn will check Primero for data once every year in order to extract indicator results that will be reported on and visualized in an external DB.
Create Jobs 1 & 2 in which OpenFn gets cases and services from Primero, maps the Primero extract and upserts to the ONA Postgres database.
GET /api/v2/cases
-- where "type_of_case" = "Children Undergoing Reintegration"GET /api/v2/cases
-- where where Age < 18 yearsSee data flow diagram.
state.json
Job 1: Get cases from Primero
Example for the cursor above: If the job cron trigger runs on
Jan 1, 2022
, we want to GET cases that would have been created beforeJan 1, 2022
but afterJan 1, 2021
.Job 2: Load to DB
adaptor
Primero PostgreSQL
expression.js
2 new jobs to create in a new
dashboard
directory in this repo.trigger