diff --git a/index.js b/index.js index 1915f0bc19f3ab6b0a1dbd11779942326fdadf86..8c53b54ca0a63b47dad25e35974433a5500ef426 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 2e0bba113cfe88a702f98d7de96adca622aedf41..f767edb92e806dcebe814522aa3db1694c5453bb 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",