From 22a8d736be1a85e9c174e247f7c84cfa1bba54f9 Mon Sep 17 00:00:00 2001
From: rpapin <rpapin@grandlyon.com>
Date: Fri, 12 Feb 2021 09:41:45 +0100
Subject: [PATCH] change period in fct of manual job or automatic

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

diff --git a/src/index.js b/src/index.js
index 8240c81..ef68af9 100755
--- a/src/index.js
+++ b/src/index.js
@@ -15,9 +15,12 @@ require('moment-timezone')
 moment.locale('fr') // set the language
 moment.tz.setDefault('Europe/Paris') // set the timezone
 
-const startDate = moment()
-  .subtract(1, 'year')
-  .format('YYYY-MM-DD')
+const manualExecution =
+  process.env.COZY_JOB_MANUAL_EXECUTION === 'true' ? true : false
+const startDate = manualExecution
+  ? moment().subtract(1, 'year').format('YYYY-MM-DD')
+  : moment().subtract(3, 'year').format('YYYY-MM-DD')
+  
 const endDate = moment()
   .startOf('day')
   .subtract(1, 'day')
-- 
GitLab