diff --git a/src/index.js b/src/index.js index 1c39be03eef596a67137ab90b756ab27d3c373c5..f660550f6b4dee163f42fb7db93183239439bb52 100644 --- a/src/index.js +++ b/src/index.js @@ -15,8 +15,8 @@ moment.tz.setDefault("Europe/Paris"); // set the timezone const startDate = moment() .startOf("year") - // .subtract(3, 'year') TODO PUT TERNARY EXPRESSION FOR MANUAL LAUNCH - .subtract(1, "year") + // .subtract(3, "year") + .subtract(6, 'month') .subtract(1, "day") .format("MM/DD/YYYY"); const endDate = moment().format("MM/DD/YYYY"); @@ -71,7 +71,12 @@ async function processData(timeStep, response, baseUrl, apiAuthKey) { log("info", "Saving data to Cozy"); log("info", "Response length : " + loadProfile.length); if (doctype === rangeDate.day.doctype) { - log("info", "Saving daily data" + loadProfile); + loadProfile.map(v => { + log( + "info", + "Saving daily data " + v.load + " for " + v.day + "/" + v.month + ); + }); await storeData(loadProfile, rangeDate.day.doctype, rangeDate.day.keys); } else if (doctype === rangeDate.month.doctype) { await resetInProgressAggregatedData(rangeDate.month.doctype); @@ -153,6 +158,7 @@ function format(response) { .slice(1) .filter(value => value.ValeurIndex); const dataLen = data.length; + log("info", "filtered size is : " + dataLen); const mapData = data.map((value, index) => { const time = moment(value.DateReleve, moment.ISO_8601); if (index + 1 < dataLen) { @@ -163,7 +169,10 @@ function format(response) { " SUBSTRACTING : " + data[index + 1].ValeurIndex + " - " + - value.ValeurIndex + ' == ' + data[index + 1].ValeurIndex - value.ValeurIndex + + value.ValeurIndex + + " == " + + data[index + 1].ValeurIndex - + value.ValeurIndex + "\n" ); return { @@ -176,6 +185,7 @@ function format(response) { type: value.TypeAgregat }; } else { + log("info", "end of data - date is : " + value.DateReleve); return { load: null, year: parseInt(time.format("YYYY")),