Commit 0f1f26ec authored by git-directory-deploy's avatar git-directory-deploy
Browse files

publish: build delivery

generated from commit 9b6286f5
parent c2d48782
...@@ -129,6 +129,7 @@ const { ...@@ -129,6 +129,7 @@ const {
hydrateAndFilter, hydrateAndFilter,
cozyClient cozyClient
} = __webpack_require__(1); } = __webpack_require__(1);
const rp = __webpack_require__(22); const rp = __webpack_require__(22);
const moment = __webpack_require__(1045); const moment = __webpack_require__(1045);
__webpack_require__(1174); __webpack_require__(1174);
...@@ -136,12 +137,12 @@ __webpack_require__(1174); ...@@ -136,12 +137,12 @@ __webpack_require__(1174);
moment.locale("fr"); // set the language moment.locale("fr"); // set the language
moment.tz.setDefault("Europe/Paris"); // set the timezone moment.tz.setDefault("Europe/Paris"); // set the timezone
   
const startDate = moment() const manualExecution = process.env.COZY_JOB_MANUAL_EXECUTION === "true" ? true : false
.startOf("year")
// .subtract(3, "year") const startDate = manualExecution
.subtract(1, "month") ? moment().startOf("year").subtract(1, "year").format("MM/DD/YYYY")
.subtract(1, "day") : moment().startOf("year").subtract(3, "year").format("MM/DD/YYYY")
.format("MM/DD/YYYY");
const endDate = moment().format("MM/DD/YYYY"); const endDate = moment().format("MM/DD/YYYY");
const timeRange = ["day", "month", "year"]; const timeRange = ["day", "month", "year"];
const rangeDate = { const rangeDate = {
...@@ -189,10 +190,8 @@ async function start(fields, cozyParameters) { ...@@ -189,10 +190,8 @@ async function start(fields, cozyParameters) {
} }
async function processData(timeStep, response, baseUrl, apiAuthKey) { async function processData(timeStep, response, baseUrl, apiAuthKey) {
const doctype = rangeDate[timeStep].doctype; const doctype = rangeDate[timeStep].doctype;
log("info", "Getting data TIMESTEP : " + timeStep);
const loadProfile = await getData(response, baseUrl, apiAuthKey); const loadProfile = await getData(response, baseUrl, apiAuthKey);
log("info", "Saving data to Cozy"); log("info", "Saving data to Cozy");
log("info", "Response length : " + loadProfile.length);
if (doctype === rangeDate.day.doctype) { if (doctype === rangeDate.day.doctype) {
await storeData(loadProfile, rangeDate.day.doctype, rangeDate.day.keys); await storeData(loadProfile, rangeDate.day.doctype, rangeDate.day.keys);
} else if (doctype === rangeDate.month.doctype) { } else if (doctype === rangeDate.month.doctype) {
...@@ -280,15 +279,6 @@ function format(response) { ...@@ -280,15 +279,6 @@ function format(response) {
const mapData = data.map((value, index) => { const mapData = data.map((value, index) => {
const time = moment(value.DateReleve, moment.ISO_8601); const time = moment(value.DateReleve, moment.ISO_8601);
if (index + 1 < dataLen) { if (index + 1 < dataLen) {
log(
"info",
"date is " +
value.DateReleve +
" SUBSTRACTING : " +
data[index + 1].ValeurIndex +
" - " +
value.ValeurIndex
);
return { return {
load: data[index + 1].ValeurIndex - value.ValeurIndex, load: data[index + 1].ValeurIndex - value.ValeurIndex,
year: parseInt(time.format("YYYY")), year: parseInt(time.format("YYYY")),
...@@ -371,9 +361,9 @@ function reduceMonthFunction(acc, x) { ...@@ -371,9 +361,9 @@ function reduceMonthFunction(acc, x) {
async function storeData(data, doctype, filterKeys) { async function storeData(data, doctype, filterKeys) {
log("debug", "Store into " + doctype); log("debug", "Store into " + doctype);
log("debug", "Store into keys : " + filterKeys); log("debug", "Store into keys : " + filterKeys);
data.map(v => { // data.map(v => {
log("info", "Saving data " + v.load + " for " + v.day + "/" + v.month + "/" + v.year); // log("info", "Saving data " + v.load + " for " + v.day + "/" + v.month + "/" + v.year);
}); // });
const filteredDocuments = await hydrateAndFilter(data, doctype, { const filteredDocuments = await hydrateAndFilter(data, doctype, {
keys: filterKeys keys: filterKeys
}) })
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment