From e372fd6e9f6c6ab438e4c8615045d87b87c10ef4 Mon Sep 17 00:00:00 2001
From: Pierre Ecarlat <pecarlat@grandlyon.com>
Date: Mon, 17 Jun 2024 13:42:44 +0000
Subject: [PATCH] fix(data): aborts if no data

---
 src/index.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/index.js b/src/index.js
index 8370c8d..cca7b00 100755
--- a/src/index.js
+++ b/src/index.js
@@ -142,7 +142,7 @@ async function start(fields, cozyParameters) {
       dataStartDate.format('YYYY-MM-DD'),
       dataEndDate.format('YYYY-MM-DD')
     )
-    if (!grdfData) {
+    if (grdfData.length == 0) {
       log('debug', 'No data found')
       transaction.setStatus(Tracing.SpanStatus.Ok)
       transaction.finish()
@@ -163,6 +163,7 @@ async function start(fields, cozyParameters) {
       rangeDate.day.doctype,
       rangeDate.day.keys
     )
+
     const { year: firstYear, month: firstMonth } = grdfData[0]
 
     log('debug', 'Aggregate GRDF yearly load data')
-- 
GitLab