From 9a6be9f926679c4be88d5542d501722a2dbe4edc Mon Sep 17 00:00:00 2001 From: build-token <build-token> Date: Tue, 20 Sep 2022 09:24:17 +0000 Subject: [PATCH] publish: konnector config example generated from commit 47e75f01af8711b17aa3fea45a0eac8c15049aff --- index.js | 9 ++++++++- package.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1915f0b..8c53b54 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,7 @@ module.exports = new BaseKonnector(start) */ async function start(fields, cozyParameters) { log('info', 'Konnector configuration ...') + log('info', `isManual exectuion: ${manualExecution}`) const pointId = parseInt(fields.pointId) let baseUrl = fields.wso2BaseUrl @@ -112,6 +113,7 @@ async function start(fields, cozyParameters) { log('info', 'User Logging...') if (isFirstStart(await getAccount(ACCOUNT_ID))) { + log('info', 'First start...') const user = await verifyUserIdentity(fields, baseUrl, apiAuthKey, sgeLogin) let consent = await createBoConsent( @@ -376,7 +378,8 @@ async function getMaxPowerData(url, apiAuthKey, userLogin, pointId) { /** * If start date exceed the maximum amount of data we can get with one query - * get only 36 month + * get only 36 month. + * On manual execution, set the start date to one year ago. */ function setStartDate() { if (moment(endDate).diff(startDailyDate, 'months', true) > 36) { @@ -387,6 +390,10 @@ function setStartDate() { startDailyDate = moment(endDate).subtract(36, 'month') startDailyDateString = startDailyDate.format('YYYY-MM-DD') } + if (manualExecution) { + startDailyDate = moment(endDate).subtract(12, 'month') + startDailyDateString = startDailyDate.format('YYYY-MM-DD') + } } /** diff --git a/package.json b/package.json index 2e0bba1..f767edb 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "xml2js": "^0.4.23" }, "devDependencies": { - "cozy-jobs-cli": "1.19.2", + "cozy-jobs-cli": "1.19.1", "cozy-konnector-build": "1.3.4", "eslint-config-cozy-app": "1.3.3", "eslint-plugin-prettier": "^4.0.0", -- GitLab