diff --git a/source/package.json b/source/package.json index e05113bde10ac5174155fb6995c8d789b119d8f8..e13c7c6c2405071e4fc323c2eda7c91db19a11f1 100644 --- a/source/package.json +++ b/source/package.json @@ -1,6 +1,6 @@ { "name": "cozy-konnector-template", - "version": "1.0.0", + "version": "1.1.0", "description": "", "repository": { "type": "git", diff --git a/source/src/index.js b/source/src/index.js index a96c346cb07d4927a87861c73bc4aef934d81545..ff518231f776fc47f27a4c2fa44d502413af68c0 100644 --- a/source/src/index.js +++ b/source/src/index.js @@ -219,7 +219,6 @@ function aggregating(data, doctype) { const reducer = (accumulator, currentValue) => accumulator + currentValue.load if (doctype === rangeDate.an.doctype) { const year = moment().year() - // console.log(data) var filtered = data.filter(function(el) { return el.year == year }) @@ -288,6 +287,7 @@ async function storeData(data, doctype, keys) { log('debug', 'Store into ' + doctype) log('debug', data, 'Store into ') log('debug', keys, 'Store into keys ') + data = removeNullData(data) return hydrateAndFilter(data, doctype, { keys: keys }).then(filteredDocuments => { @@ -334,3 +334,10 @@ async function resetInProgressAggregatedData(doctype) { } } } + +function removeNullData(data) { + return data.filter( + element => + !isNaN(element.load) && !isNaN(element.year) && !isNaN(element.month) + ) +}