From 82796c95969bbd767cd3546803145002009d3143 Mon Sep 17 00:00:00 2001 From: "ext.sopra.yvallet@grandlyon.com" <ext.sopra.yvallet@grandlyon.com> Date: Fri, 19 Feb 2021 14:30:18 +0100 Subject: [PATCH] publish: a generated from commit 9021edaa5522b788d3a15ba1c87f0d8cf5d3eb08 --- index.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 4df584d..f26b325 100644 --- a/index.js +++ b/index.js @@ -273,11 +273,11 @@ async function getData(response, baseUrl, apiAuthKey) { function format(response) { const data = response.resultatRetour .slice(1) - .filter(value => { - value.TypeAgregat === 'R' - }) - .map((value, index) => { - const time = moment(value.DateReleve, moment.ISO_8601) + .filter(value => value.ValeurIndex) + const dataLen = data.length + data.map((value, index) => { + const time = moment(value.DateReleve, moment.ISO_8601) + if (index + 1 < dataLen) { log( 'info', 'date -> ' + @@ -289,7 +289,7 @@ function format(response) { '\n' ) return { - load: value.ValeurIndex - response.resultatRetour[index].ValeurIndex, + load: data[index + 1].ValeurIndex - value.ValeurIndex, year: parseInt(time.format('YYYY')), month: parseInt(time.format('M')), day: parseInt(time.format('D')), @@ -297,7 +297,18 @@ function format(response) { minute: 0, type: value.TypeAgregat } - }) + } else { + return { + load: null, + year: parseInt(time.format('YYYY')), + month: parseInt(time.format('M')), + day: parseInt(time.format('D')), + hour: 0, + minute: 0, + type: value.TypeAgregat + } + } + }) log('info', 'DATALOAD LIST\n') data.map(value => { log( -- GitLab