Closed aleksa-krolls closed 3 years ago
If state.data.defaultUnit: "kilograms" --> multiply quantity by 1000 to convert kg to grams. This way the massin_grams value will be correct. If state.data.defaultUnit is not defined/ not present in the payload, OR if it does not equal kilograms, then continue to map the Kobo quantity as is https://github.com/OpenFn/wcs-wildmeat/blob/fb6b84974181a46eb9e2a2a3d2eeb2381fc46562/jobs/rural-consumption-to-postgres.js#L90
state.data.defaultUnit: "kilograms"
quantity
massin_grams
state.data.defaultUnit
kilograms
See LP for Wildmeat Postgres Use this: https://www.openfn.org/projects/p5yaxp/messages/mbpqw5qr
Wildmeat Postgres
language-postgresql
https://github.com/OpenFn/wcs-wildmeat/blob/fb6b84974181a46eb9e2a2a3d2eeb2381fc46562/jobs/rural-consumption-to-postgres.js#L90
This state should return a massin_grams of 11,000 (11 kg * 1000).
11,000
Request
If
state.data.defaultUnit: "kilograms"
--> multiplyquantity
by 1000 to convert kg to grams. This way themassin_grams
value will be correct. Ifstate.data.defaultUnit
is not defined/ not present in the payload, OR if it does not equalkilograms
, then continue to map the Koboquantity
as is https://github.com/OpenFn/wcs-wildmeat/blob/fb6b84974181a46eb9e2a2a3d2eeb2381fc46562/jobs/rural-consumption-to-postgres.js#L90state
See LP for
Wildmeat Postgres
Use this: https://www.openfn.org/projects/p5yaxp/messages/mbpqw5qradaptor
language-postgresql
expression
https://github.com/OpenFn/wcs-wildmeat/blob/fb6b84974181a46eb9e2a2a3d2eeb2381fc46562/jobs/rural-consumption-to-postgres.js#L90
output
This state should return a
massin_grams
of11,000
(11 kg * 1000).