diff --git a/index.js b/index.js index 7fd17058bb122995eb7360b0ee146f1ffeba3136..3562ff9354f04223d59b0ee9e7161a9b3aa62d08 100644 --- a/index.js +++ b/index.js @@ -138,8 +138,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"); @@ -194,7 +194,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); @@ -276,6 +281,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) { @@ -286,7 +292,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 { @@ -299,6 +308,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")),