From d7ae749ffab281735670e6a705c21a33a1debde3 Mon Sep 17 00:00:00 2001 From: build-pipeline <build-token> Date: Thu, 3 Mar 2022 09:38:28 +0000 Subject: [PATCH] publish: Merge branch '225-alerte-eau-pb-date-dans-template' into 'dev' generated from commit 50b9a8112ca90e9c6eae1444aa9358695f53e8aa --- services/consumptionAlert/ecolyo.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/services/consumptionAlert/ecolyo.js b/services/consumptionAlert/ecolyo.js index 9b9f9f0e9..f00cc5a30 100644 --- a/services/consumptionAlert/ecolyo.js +++ b/services/consumptionAlert/ecolyo.js @@ -77148,11 +77148,19 @@ const consumptionAlert = async ({ const fetchedData = await consumptionService.getLastDataload(_fluid.FluidType.WATER); let lastDayValue = 0; + let alertDay = _luxon.DateTime.local().setZone('utc', { + keepLocalTime: true + }); + if (fetchedData && fetchedData.length > 0) { fetchedData.forEach(element => { if (element.value) { lastDayValue = element.value; } + + if (element.date) { + alertDay = element.date; + } }); } @@ -77163,11 +77171,6 @@ const consumptionAlert = async ({ log('info', 'Creation of mail...'); const mailService = new _mail.default(); - - const today = _luxon.DateTime.local().setZone('utc', { - keepLocalTime: true - }); - const environmentService = new _environment.default(); const template = consumptionLimit({ title: 'Ça déborde !', @@ -77176,7 +77179,7 @@ const consumptionAlert = async ({ clientUrl: `${appLink}/#/consumption/water`, unsubscribeUrl: `${appLink}/#/options`, userLimit: userProfil.waterDailyConsumptionLimit, - limitDate: `${today.day} ${(0, _utils.getPreviousMonthName)(today)}` + limitDate: `${alertDay.day} ${(0, _utils.getPreviousMonthName)(alertDay)}` }); const mailData = { mode: 'noreply', -- GitLab