From 6f3615e58bc09d0e218ba1c88b8a0f06541fd489 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Wed, 26 Feb 2020 13:04:58 +0100
Subject: [PATCH] feat: remove null data from imported data

---
 source/package.json | 2 +-
 source/src/index.js | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/source/package.json b/source/package.json
index e05113b..e13c7c6 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 a96c346..ff51823 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)
+  )
+}
-- 
GitLab