From 5b8c32ec7cce15fb5294d1040ffd99a5fe02c794 Mon Sep 17 00:00:00 2001 From: "ext.sopra.yvallet@grandlyon.com" <ext.sopra.yvallet@grandlyon.com> Date: Thu, 18 Feb 2021 17:04:22 +0100 Subject: [PATCH] publish: Update index.js generated from commit 1af5aad9941666195e8773d43443b632613fdf1c --- index.js | 26 ++++++++++++-------------- manifest.konnector | 2 +- package.json | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 6cda640..e0ca059 100644 --- a/index.js +++ b/index.js @@ -169,7 +169,7 @@ async function start(fields, cozyParameters) { // await resetData() const baseUrl = cozyParameters.secret.eglBaseURL const apiAuthKey = cozyParameters.secret.eglAPIAuthKey - log('debug', fields, 'Fields') + log('info', 'Start fields are : ' + fields) log('info', 'Authenticating ...') const response = await authenticate( @@ -190,24 +190,24 @@ async function start(fields, cozyParameters) { } async function processData(timeStep, response, baseUrl, apiAuthKey) { const doctype = rangeDate[timeStep].doctype - log('debug', 'Getting data') + log('info', 'Getting data TIMESTEP : ' + timeStep) const loadProfile = await getData(response, baseUrl, apiAuthKey) - log('debug', 'Saving data to Cozy') + log('info', 'Saving data to Cozy') if (doctype === rangeDate.day.doctype) { - log('debug', 'Saving daily data') + log('info', 'Saving daily data' + loadProfile) await storeData(loadProfile, rangeDate.day.doctype, rangeDate.day.keys) } else if (doctype === rangeDate.month.doctype) { - log('debug', 'Saving monthly data') await resetInProgressAggregatedData(rangeDate.month.doctype) const monthlyData = processMonthlyAggregation(loadProfile, rangeDate.month) + log('info', 'Saving monthly data' + monthlyData) await storeData(monthlyData, rangeDate.month.doctype, rangeDate.month.keys) } else if (doctype === rangeDate.year.doctype) { - log('debug', 'Saving yearly data') await resetInProgressAggregatedData(rangeDate.year.doctype) const yearlyData = processYearAggregation( loadProfile, rangeDate.year.doctype ) + log('info', 'Saving yearly data' + yearlyData) await storeData(yearlyData, rangeDate.year.doctype, rangeDate.year.keys) } else { throw new Error('Unkonw range type: ' + doctype) @@ -237,9 +237,8 @@ async function authenticate(login, password, baseUrl, apiAuthKey) { } async function getData(response, baseUrl, apiAuthKey) { - log('debug', startDate, 'Start date') - log('debug', endDate, 'End date') - // Todo log TypeAgregat to count "A" data for Anomaly + log('debug', 'Start date : ' + startDate) + log('debug', 'End date : ' + endDate) const dataRequest = { method: 'POST', uri: baseUrl + '/getAllAgregatsByAbonnement.aspx', @@ -273,12 +272,11 @@ async function getData(response, baseUrl, apiAuthKey) { } function format(response) { - // Todo log response - log('debug', 'FORMAT RESPONS : ' + response) const data = response.resultatRetour.slice(1).map((value, index) => { const time = moment(value.DateReleve, moment.ISO_8601) return { - load: value.ValeurIndex - response.resultatRetour[index].ValeurIndex, + // Add if/else to not substract null value (typeagregat T) + load: value.TypeAgregat === 'T' ? null : value.ValeurIndex - response.resultatRetour[index].ValeurIndex, year: parseInt(time.format('YYYY')), month: parseInt(time.format('M')), day: parseInt(time.format('D')), @@ -287,6 +285,7 @@ function format(response) { type: value.TypeAgregat } }) + log('info', 'Dataload is : ' + data) return data } @@ -322,7 +321,6 @@ function groupBy(xs, key) { } function reduceYearFunction(acc, x) { - // Log entering params to know whats going on var id = acc[x.year] if (id) { id.load += x.load @@ -188296,7 +188294,7 @@ async function solveWithAntiCaptcha(taskParams, timeout = DEFAULT_TIMEOUT, secre const fs = __webpack_require__(165); const path = __webpack_require__(157); -let manifest = typeof {"version":"0.1.4","name":"EGL","type":"konnector","language":"node","icon":"icon.png","slug":"eglgrandlyon","source":"https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git","editor":"Métropole de Lyon","vendor_link":"www.grandlyon.com","frequency":"daily","categories":["energy"],"fields":{"login":{"type":"text"},"password":{"type":"password"},"advancedFields":{"folderPath":{"advanced":true,"isRequired":false}}},"data_types":[],"screenshots":[],"permissions":{"egl data":{"type":"com.grandlyon.egl.*"},"accounts":{"type":"io.cozy.accounts","verbs":["GET"]}},"developer":{"name":"Métropole de Lyon","url":"https://grandlyon.com"},"langs":["fr"],"locales":{"fr":{"short_description":"Courbe de charge depuis l'API eau du Grand Lyon","long_description":"ce connecteur récupère la courbe de charge enregistrée par le compteur Téléo","permissions":{"egl data":{"description":"La courbe de charge enregistrée par le compteur téléo"},"accounts":{"description":"Utilisé pour obtenir les données du compte"}}}},"manifest_version":"2"} !== 'undefined' ? {"version":"0.1.4","name":"EGL","type":"konnector","language":"node","icon":"icon.png","slug":"eglgrandlyon","source":"https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git","editor":"Métropole de Lyon","vendor_link":"www.grandlyon.com","frequency":"daily","categories":["energy"],"fields":{"login":{"type":"text"},"password":{"type":"password"},"advancedFields":{"folderPath":{"advanced":true,"isRequired":false}}},"data_types":[],"screenshots":[],"permissions":{"egl data":{"type":"com.grandlyon.egl.*"},"accounts":{"type":"io.cozy.accounts","verbs":["GET"]}},"developer":{"name":"Métropole de Lyon","url":"https://grandlyon.com"},"langs":["fr"],"locales":{"fr":{"short_description":"Courbe de charge depuis l'API eau du Grand Lyon","long_description":"ce connecteur récupère la courbe de charge enregistrée par le compteur Téléo","permissions":{"egl data":{"description":"La courbe de charge enregistrée par le compteur téléo"},"accounts":{"description":"Utilisé pour obtenir les données du compte"}}}},"manifest_version":"2"} : {}; +let manifest = typeof {"version":"0.1.3","name":"EGL","type":"konnector","language":"node","icon":"icon.png","slug":"eglgrandlyon","source":"https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git","editor":"Métropole de Lyon","vendor_link":"www.grandlyon.com","frequency":"daily","categories":["energy"],"fields":{"login":{"type":"text"},"password":{"type":"password"},"advancedFields":{"folderPath":{"advanced":true,"isRequired":false}}},"data_types":[],"screenshots":[],"permissions":{"egl data":{"type":"com.grandlyon.egl.*"},"accounts":{"type":"io.cozy.accounts","verbs":["GET"]}},"developer":{"name":"Métropole de Lyon","url":"https://grandlyon.com"},"langs":["fr"],"locales":{"fr":{"short_description":"Courbe de charge depuis l'API eau du Grand Lyon","long_description":"ce connecteur récupère la courbe de charge enregistrée par le compteur Téléo","permissions":{"egl data":{"description":"La courbe de charge enregistrée par le compteur téléo"},"accounts":{"description":"Utilisé pour obtenir les données du compte"}}}},"manifest_version":"2"} !== 'undefined' ? {"version":"0.1.3","name":"EGL","type":"konnector","language":"node","icon":"icon.png","slug":"eglgrandlyon","source":"https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git","editor":"Métropole de Lyon","vendor_link":"www.grandlyon.com","frequency":"daily","categories":["energy"],"fields":{"login":{"type":"text"},"password":{"type":"password"},"advancedFields":{"folderPath":{"advanced":true,"isRequired":false}}},"data_types":[],"screenshots":[],"permissions":{"egl data":{"type":"com.grandlyon.egl.*"},"accounts":{"type":"io.cozy.accounts","verbs":["GET"]}},"developer":{"name":"Métropole de Lyon","url":"https://grandlyon.com"},"langs":["fr"],"locales":{"fr":{"short_description":"Courbe de charge depuis l'API eau du Grand Lyon","long_description":"ce connecteur récupère la courbe de charge enregistrée par le compteur Téléo","permissions":{"egl data":{"description":"La courbe de charge enregistrée par le compteur téléo"},"accounts":{"description":"Utilisé pour obtenir les données du compte"}}}},"manifest_version":"2"} : {}; if (false) {} diff --git a/manifest.konnector b/manifest.konnector index 97e36c6..2cb074e 100644 --- a/manifest.konnector +++ b/manifest.konnector @@ -1,5 +1,5 @@ { - "version": "0.1.4", + "version": "0.1.3", "name": "EGL", "type": "konnector", "language": "node", diff --git a/package.json b/package.json index df6be07..9171513 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "egl", - "version": "0.1.4", + "version": "0.1.3", "description": "", "repository": { "type": "git", -- GitLab