From 8f0a9b314d20156c51ccdc91bbfd3cc8c7f5dad5 Mon Sep 17 00:00:00 2001 From: Aleksa Krolls Date: Tue, 24 Sep 2024 17:05:18 +0300 Subject: [PATCH] ddetoeuf@wcs.org's change on OpenFn.org --- ngrt/2019.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ngrt/2019.js b/ngrt/2019.js index 2ac9da6f..20eaf4d9 100644 --- a/ngrt/2019.js +++ b/ngrt/2019.js @@ -47,6 +47,15 @@ upsert('WCSPROGRAMS_KoboNrgtNrgtanswer', 'AnswerId', { }, Surveyor: dataValue('surveyor'), GovGroup: dataValue('gov_group'), + SurveyDate: state => { + const date = state.data.today || state.data._submission_time + if (Number(date.split('-')[0]) >= 2014 ) { + return date + } + return 2019 + // If the time/date is not properly set on the device used to collect the data, the year of "today" will be 2000. + // With the code above we are replacing any 2000 by 2019: + }, LastUpdate: new Date().toISOString(), }); upsert('WCSPROGRAMS_KoboNrgtNrgtanswergs', 'AnswerId', { @@ -60,6 +69,8 @@ upsert('WCSPROGRAMS_KoboNrgtNrgtanswergs', 'AnswerId', { return date } return 2019 + // If the time/date is not properly set on the device used to collect the data, the year of "today" will be 2000. + // With the code above we are replacing any 2000 by 2019: }, Gender: dataValue('gender'), Member: dataValue('member'),