Skip to content
Snippets Groups Projects
Commit 37ba66de authored by build-token's avatar build-token
Browse files

publish: feat: reduce fetching data to 1y on manual exec

generated from commit 78e782c3
parent f96dd342
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,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 +377,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 +389,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')
}
}
 
/**
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment