In the Offtake job, update wildmeat_id on tbl_wildmeat_hunter to map to animal['animal_details/species_id'] & the position of the animal item in the array. For example, in this state, the first entry for wildmeat_id would be 12601.
In the Urban Consumption job, update wildmeat_id on tbl_wildmeat_urban to map to domeat_consumption/domeat_species & the position of the item in the string. For example, say we get this in state:
"domeat_consumption/domeat_species": "100089 100086"
The first entry would be 1000891 & the second one would be 1000862.
Background, context, and business value
@lakhassane added this code to the Market job to make sure the
wildmeat_id
ontbl_wildmeat_market
is always unique. Let's make a similar change to the other 2 jobs to ensure thewildmeat_id
is always unique and to resolve this error: https://www.openfn.org/projects/p5yaxp/runs/0616ed56-cc8d-72cf-b796-58faa59b7b7b.The specific request, in as few words as possible
In the Offtake job, update
wildmeat_id
ontbl_wildmeat_hunter
to map toanimal['animal_details/species_id']
& the position of the animal item in the array. For example, in this state, the first entry forwildmeat_id
would be 12601.In the Urban Consumption job, update
wildmeat_id
ontbl_wildmeat_urban
to map todomeat_consumption/domeat_species
& the position of the item in the string. For example, say we get this in state:"domeat_consumption/domeat_species": "100089 100086"
The first entry would be 1000891 & the second one would be 1000862.You can test your changes for Offtake by rerunning this transaction: https://www.openfn.org/projects/p5yaxp/runs/0616ed56-cc8d-72cf-b796-58faa59b7b7b.
state.json
Offtake: https://www.openfn.org/projects/p5yaxp/messages/0616ed56-b782-7182-8151-bfbb6b738a87 Urban Consumption: https://www.openfn.org/projects/p5yaxp/messages/0616db01-ca53-7b83-bdaf-26ca8be4c50b Postgres DB: See LP Wildmeat Postgres Transitional DB (WCS)
expression.js
Urban Consumption: https://github.com/OpenFn/wcs-wildmeat/blob/master/jobs/2.a.consommationUrbaine.js Offtake: https://github.com/OpenFn/wcs-wildmeat/blob/master/jobs/2.d.Offtake.js