From 45c3237ac8e1484d1c2bed6b6a3b3b80d82a8be0 Mon Sep 17 00:00:00 2001 From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com> Date: Tue, 11 Jan 2022 09:14:46 +0000 Subject: [PATCH] fix: remove duplicate hydrateAndFilter --- manifest.konnector | 2 +- package.json | 2 +- src/index.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest.konnector b/manifest.konnector index 5e5628c..d32acd6 100644 --- a/manifest.konnector +++ b/manifest.konnector @@ -1,5 +1,5 @@ { - "version": "1.1.0", + "version": "1.1.1", "name": "Enedis", "type": "konnector", "language": "node", diff --git a/package.json b/package.json index 8cdba5a..e288f2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "enedis", - "version": "1.1.0", + "version": "1.1.1", "description": "", "repository": { "type": "git", diff --git a/src/index.js b/src/index.js index 4f0a09c..0317d0b 100644 --- a/src/index.js +++ b/src/index.js @@ -19,15 +19,19 @@ moment.tz.setDefault('Europe/Paris') // set the timezone /*** Connector Constants ***/ const manualExecution = process.env.COZY_JOB_MANUAL_EXECUTION === 'true' ? true : false +// Period for daily data const startDailyDate = manualExecution ? moment().subtract(12, 'month') : moment().subtract(32, 'month') const startDailyDateString = startDailyDate.format('YYYY-MM-DD') +// Period for half and hour data const startLoadDate = moment().subtract(7, 'day') const startLoadDateString = startLoadDate.format('YYYY-MM-DD') +// Period to define if the history is loaded const checkHistoryDate = moment().subtract(8, 'day') const endDate = moment() const endDateString = endDate.format('YYYY-MM-DD') +// Endpoints config const baseUrl = 'https://gw.prd.api.enedis.fr' const dailyDataURL = `${baseUrl}/v4/metering_data/daily_consumption` const loadCurveURL = `${baseUrl}/v4/metering_data/consumption_load_curve` @@ -359,13 +363,9 @@ async function processData(data, doctype, filterKeys) { const parsedData = JSON.parse(data) const intervalData = parsedData.meter_reading.interval_reading const formatedData = await formateData(intervalData, doctype) - // Remove data for existing days into the DB - const filteredData = await hydrateAndFilter(formatedData, doctype, { - keys: filterKeys, - }) // Store new day data - await storeData(filteredData, doctype, filterKeys) - return filteredData + const storedData = await storeData(formatedData, doctype, filterKeys) + return storedData } /** -- GitLab