From 6fcc6b059901166601ec0578cd68af4996a9e5f8 Mon Sep 17 00:00:00 2001
From: Hugo <hnouts.dev@gmail.com>
Date: Fri, 19 Feb 2021 17:19:55 +0100
Subject: [PATCH] new log

---
 src/index.js | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/index.js b/src/index.js
index f660550..7372806 100644
--- a/src/index.js
+++ b/src/index.js
@@ -16,7 +16,7 @@ moment.tz.setDefault("Europe/Paris"); // set the timezone
 const startDate = moment()
   .startOf("year")
   // .subtract(3, "year")
-  .subtract(6, 'month')
+  .subtract(6, "month")
   .subtract(1, "day")
   .format("MM/DD/YYYY");
 const endDate = moment().format("MM/DD/YYYY");
@@ -71,17 +71,11 @@ async function processData(timeStep, response, baseUrl, apiAuthKey) {
   log("info", "Saving data to Cozy");
   log("info", "Response length : " + loadProfile.length);
   if (doctype === rangeDate.day.doctype) {
-    loadProfile.map(v => {
-      log(
-        "info",
-        "Saving daily data " + v.load + " for " + v.day + "/" + v.month
-      );
-    });
     await storeData(loadProfile, rangeDate.day.doctype, rangeDate.day.keys);
   } else if (doctype === rangeDate.month.doctype) {
     await resetInProgressAggregatedData(rangeDate.month.doctype);
     const monthlyData = processMonthlyAggregation(loadProfile, rangeDate.month);
-    log("info", "Saving monthly data" + monthlyData);
+    log("info", "Saving monthly data");
     await storeData(monthlyData, rangeDate.month.doctype, rangeDate.month.keys);
   } else if (doctype === rangeDate.year.doctype) {
     await resetInProgressAggregatedData(rangeDate.year.doctype);
@@ -89,7 +83,7 @@ async function processData(timeStep, response, baseUrl, apiAuthKey) {
       loadProfile,
       rangeDate.year.doctype
     );
-    log("info", "Saving yearly data" + yearlyData);
+    log("info", "Saving yearly data");
     await storeData(yearlyData, rangeDate.year.doctype, rangeDate.year.keys);
   } else {
     throw new Error("Unkonw range type: " + doctype);
@@ -164,16 +158,12 @@ function format(response) {
     if (index + 1 < dataLen) {
       log(
         "info",
-        "date -> " +
+        "date is " +
           value.DateReleve +
           " SUBSTRACTING : " +
           data[index + 1].ValeurIndex +
           " - " +
-          value.ValeurIndex +
-          " == " +
-          data[index + 1].ValeurIndex -
-          value.ValeurIndex +
-          "\n"
+          value.ValeurIndex
       );
       return {
         load: data[index + 1].ValeurIndex - value.ValeurIndex,
@@ -253,7 +243,10 @@ function reduceMonthFunction(acc, x) {
 
 async function storeData(data, doctype, keys) {
   log("debug", "Store into " + doctype);
-  log("debug", keys, "Store into keys ");
+  log("debug", "Store into keys : " + keys);
+  data.map(v => {
+    log("info", "Saving data " + v.load + " for " + v.day + "/" + v.month);
+  });
   return hydrateAndFilter(data, doctype, {
     keys: keys
   }).then(filteredDocuments => {
-- 
GitLab