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 {
hydrateAndFilter,
cozyClient
} = __webpack_require__(1);
const rp = __webpack_require__(22);
const moment = __webpack_require__(1045);
__webpack_require__(1174);
......@@ -136,12 +137,12 @@ __webpack_require__(1174);
moment.locale("fr"); // set the language
moment.tz.setDefault("Europe/Paris"); // set the timezone
 
const startDate = moment()
.startOf("year")
// .subtract(3, "year")
.subtract(1, "month")
.subtract(1, "day")
.format("MM/DD/YYYY");
const manualExecution = process.env.COZY_JOB_MANUAL_EXECUTION === "true" ? true : false
const startDate = manualExecution
? moment().startOf("year").subtract(1, "year").format("MM/DD/YYYY")
: moment().startOf("year").subtract(3, "year").format("MM/DD/YYYY")
const endDate = moment().format("MM/DD/YYYY");
const timeRange = ["day", "month", "year"];
const rangeDate = {
......@@ -189,10 +190,8 @@ async function start(fields, cozyParameters) {
}
async function processData(timeStep, response, baseUrl, apiAuthKey) {
const doctype = rangeDate[timeStep].doctype;
log("info", "Getting data TIMESTEP : " + timeStep);
const loadProfile = await getData(response, baseUrl, apiAuthKey);
log("info", "Saving data to Cozy");
log("info", "Response length : " + loadProfile.length);
if (doctype === rangeDate.day.doctype) {
await storeData(loadProfile, rangeDate.day.doctype, rangeDate.day.keys);
} else if (doctype === rangeDate.month.doctype) {
......@@ -280,15 +279,6 @@ function format(response) {
const mapData = data.map((value, index) => {
const time = moment(value.DateReleve, moment.ISO_8601);
if (index + 1 < dataLen) {
log(
"info",
"date is " +
value.DateReleve +
" SUBSTRACTING : " +
data[index + 1].ValeurIndex +
" - " +
value.ValeurIndex
);
return {
load: data[index + 1].ValeurIndex - value.ValeurIndex,
year: parseInt(time.format("YYYY")),
......@@ -371,9 +361,9 @@ function reduceMonthFunction(acc, x) {
async function storeData(data, doctype, filterKeys) {
log("debug", "Store into " + doctype);
log("debug", "Store into keys : " + filterKeys);
data.map(v => {
log("info", "Saving data " + v.load + " for " + v.day + "/" + v.month + "/" + v.year);
});
// data.map(v => {
// log("info", "Saving data " + v.load + " for " + v.day + "/" + v.month + "/" + v.year);
// });
const filteredDocuments = await hydrateAndFilter(data, doctype, {
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