Commit 6fcc6b05 authored by Hugo's avatar Hugo
Browse files

new log

parent 38d9c06f
......@@ -16,7 +16,7 @@ moment.tz.setDefault("Europe/Paris"); // set the timezone
const startDate = moment()
.startOf("year")
// .subtract(3, "year")
.subtract(6, 'month')
.subtract(6, "month")
.subtract(1, "day")
.format("MM/DD/YYYY");
const endDate = moment().format("MM/DD/YYYY");
......@@ -71,17 +71,11 @@ async function processData(timeStep, response, baseUrl, apiAuthKey) {
log("info", "Saving data to Cozy");
log("info", "Response length : " + loadProfile.length);
if (doctype === rangeDate.day.doctype) {
loadProfile.map(v => {
log(
"info",
"Saving daily data " + v.load + " for " + v.day + "/" + v.month
);
});
await storeData(loadProfile, rangeDate.day.doctype, rangeDate.day.keys);
} else if (doctype === rangeDate.month.doctype) {
await resetInProgressAggregatedData(rangeDate.month.doctype);
const monthlyData = processMonthlyAggregation(loadProfile, rangeDate.month);
log("info", "Saving monthly data" + monthlyData);
log("info", "Saving monthly data");
await storeData(monthlyData, rangeDate.month.doctype, rangeDate.month.keys);
} else if (doctype === rangeDate.year.doctype) {
await resetInProgressAggregatedData(rangeDate.year.doctype);
......@@ -89,7 +83,7 @@ async function processData(timeStep, response, baseUrl, apiAuthKey) {
loadProfile,
rangeDate.year.doctype
);
log("info", "Saving yearly data" + yearlyData);
log("info", "Saving yearly data");
await storeData(yearlyData, rangeDate.year.doctype, rangeDate.year.keys);
} else {
throw new Error("Unkonw range type: " + doctype);
......@@ -164,16 +158,12 @@ function format(response) {
if (index + 1 < dataLen) {
log(
"info",
"date -> " +
"date is " +
value.DateReleve +
" SUBSTRACTING : " +
data[index + 1].ValeurIndex +
" - " +
value.ValeurIndex +
" == " +
data[index + 1].ValeurIndex -
value.ValeurIndex +
"\n"
value.ValeurIndex
);
return {
load: data[index + 1].ValeurIndex - value.ValeurIndex,
......@@ -253,7 +243,10 @@ function reduceMonthFunction(acc, x) {
async function storeData(data, doctype, keys) {
log("debug", "Store into " + doctype);
log("debug", keys, "Store into keys ");
log("debug", "Store into keys : " + keys);
data.map(v => {
log("info", "Saving data " + v.load + " for " + v.day + "/" + v.month);
});
return hydrateAndFilter(data, doctype, {
keys: keys
}).then(filteredDocuments => {
......
Markdown is supported
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