From c2d487828ac98c82cd488e0a4964aa01b5306ca1 Mon Sep 17 00:00:00 2001
From: git-directory-deploy <>
Date: Wed, 24 Feb 2021 17:11:07 +0100
Subject: [PATCH] publish: await on hydrate&filter

generated from commit a9d572b800342584d840c3b0d6a27043aee850ca
---
 index.js | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/index.js b/index.js
index f1c0b09..0ee341c 100644
--- a/index.js
+++ b/index.js
@@ -365,17 +365,19 @@ function reduceMonthFunction(acc, x) {
   return acc;
 }
 
-async function storeData(data, doctype, keys) {
+/**
+ * Save data in the right doctype db and prevent duplicated keys
+ */
+async function storeData(data, doctype, filterKeys) {
   log("debug", "Store into " + doctype);
-  log("debug", "Store into keys : " + keys);
+  log("debug", "Store into keys : " + filterKeys);
   data.map(v => {
     log("info", "Saving data " + v.load + " for " + v.day + "/" + v.month + "/" + v.year);
   });
-  return hydrateAndFilter(data, doctype, {
-    keys: keys
-  }).then(filteredDocuments => {
-    addData(filteredDocuments, doctype);
-  });
+  const filteredDocuments = await hydrateAndFilter(data, doctype, {
+    keys: filterKeys
+  })
+  return await addData(filteredDocuments, doctype)
 }
 
 /**
-- 
GitLab