Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/llle_project/ecolyo
1 result
Show changes
Commits on Source (4)
......@@ -5,6 +5,7 @@
const fs = require('fs')
const { DateTime } = require('luxon')
const config = require('./config')
const fluidConfig = require('../src/constants/config.json').fluidConfig
function getRandomNumber(min, max) {
// Generate a random float between min and max
......@@ -32,13 +33,14 @@ const generateHalfAnHourData = (startingDate, endingDate, min, max) => {
day: parsingDate.day,
hour: parsingDate.hour,
minute: parsingDate.minute,
price: load * fluidConfig[0].coefficient,
})
parsingDate = parsingDate.plus({ minute: 30 })
}
return halfAnHourDumpArray
}
const generateData = (startingDate, endingDate, min, max) => {
const generateData = (startingDate, endingDate, min, max, fluidType) => {
let parsingDate = DateTime.local(
startingDate.year,
startingDate.month,
......@@ -54,6 +56,7 @@ const generateData = (startingDate, endingDate, min, max) => {
day: parsingDate.day,
hour: 0,
minute: 0,
price: load * fluidConfig[fluidType].coefficient,
})
parsingDate = parsingDate.plus({ days: 1 })
}
......@@ -94,9 +97,11 @@ function aggregateLoadData(data, period) {
day: entryCopy.day,
hour: entryCopy.hour,
minute: entryCopy.minute,
price: entryCopy.price,
}
} else {
aggregatedData[key].load += entryCopy.load
aggregatedData[key].price += entryCopy.price
}
})
return Object.values(aggregatedData)
......@@ -125,17 +130,18 @@ const elecGeneratedDayData = generateData(
startingDate,
halfHourStartingDate.minus({ days: 1 }),
4,
8
8,
0
)
const elecDayData = [...elecAggregatedDayData, ...elecGeneratedDayData]
const elecMonthData = aggregateLoadData(elecDayData, 'month')
const elecYearData = aggregateLoadData(elecMonthData, 'year')
const gasDayData = generateData(startingDate, endingDate, 16, 68)
const gasDayData = generateData(startingDate, endingDate, 16, 68, 2)
const gasMonthData = aggregateLoadData(gasDayData, 'month')
const gasYearData = aggregateLoadData(gasMonthData, 'year')
const waterDayData = generateData(startingDate, endingDate, 200, 300)
const waterDayData = generateData(startingDate, endingDate, 200, 300, 1)
const waterMonthData = aggregateLoadData(waterDayData, 'month')
const waterYearData = aggregateLoadData(waterMonthData, 'year')
......
......@@ -24,6 +24,9 @@
<mj-section background-color="#121212">
<mj-column padding="0 32px" vertical-align="middle">
<mj-image src={{consoImageUrl}} width="132px" align="center" alt="consommation"></mj-image>
{{#unless comparisonExist }}
<mj-text color="#E3B82A" font-weight="900" font-size="20px" align="center">Oups !</mj-text>
{{/unless}}
<mj-text color="white" font-weight="900" font-size="24px">
Bonjour {{username}},
</mj-text>
......@@ -42,12 +45,22 @@
</mj-text>
{{/if}}
{{/if}}
<mj-text color="#A0A0A0" font-weight="400" font-size="18px" align="center">Retrouvez le détail de vos consommations et plus d’informations dans votre bilan Ecolyo.</mj-text>
<mj-social css-class="button-with-icon" icon-size="32px" mode="horizontal" font-size="20px" font-weight="700">
<mj-social-element src="{{baseUrl}}/assets/ecolyo-icon.png" name="ecolyo" padding="0 10px 0 0" href="{{clientUrl}}">
J’ouvre mon Ecolyo
</mj-social-element>
</mj-social>
{{#if comparisonExist }}
<mj-text color="#A0A0A0" font-weight="400" font-size="18px" align="center">Retrouvez le détail de vos consommations et plus d’informations dans votre bilan Ecolyo.</mj-text>
<mj-social css-class="button-with-icon" icon-size="32px" mode="horizontal" font-size="20px" font-weight="700">
<mj-social-element src="{{baseUrl}}/assets/ecolyo-icon.png" name="ecolyo" padding="0 10px 0 0" href="{{clientUrl}}">
J’ouvre mon Ecolyo
</mj-social-element>
</mj-social>
{{/if}}
{{#unless comparisonExist }}
<mj-text color="white" font-weight="400" font-size="18px">Nous avons constaté que vous n'avez aucun compteur connecté. Sans accès à vos données de consommation, Ecolyo ne peut pas établir de bilan individuel de celles-ci.</mj-text>
<mj-social css-class="button-with-icon" icon-size="32px" mode="horizontal" font-size="20px" font-weight="700">
<mj-social-element src="{{baseUrl}}/assets/ecolyo-icon.png" name="ecolyo" padding="0 10px 0 0" href="{{clientUrl}}">
Connecter un compteur
</mj-social-element>
</mj-social>
{{/unless}}
</mj-column>
</mj-section>
{{#if isContent}}
......
......@@ -17,10 +17,10 @@
.button table { background-color: #F1C017 !important; margin: 10px !important;
} .button-with-icon td { padding-right: 1px !important; } .button-with-icon
table { background-color: #F1C017 !important; margin-left: 10px !important;
margin-right: 10px !important; } .button-with-icon span { vertical-align:
middle !important; } .button-with-icon a { vertical-align: middle !important;
padding-right: 10px !important;} .button-with-icon a img { padding-top: 20px
!important;}
margin-right: 10px !important; border-radius: 2px !important; }
.button-with-icon span { vertical-align: middle !important; }
.button-with-icon a { vertical-align: middle !important; padding-right: 10px
!important;} .button-with-icon a img { padding-top: 20px !important;}
</mj-style>
<mj-style>
.custom-link a { color: #F1C017 !important; text-decoration: none !important;
......
......@@ -246,14 +246,16 @@ const monthlyReportNotification = async ({
const environmentService = new EnvironmentService()
const baseUrl = environmentService.getPublicURL()
const comparisonExist =
monthComparisonText.length > 0 || yearComparisonText.length > 0
const template = monthlyReportTemplate({
title: 'Infos & bilan consos',
baseUrl: baseUrl,
username: username,
clientUrl: analysisLink,
unsubscribeUrl: unsubscribeUrl,
comparisonExist:
monthComparisonText.length > 0 || yearComparisonText.length > 0,
comparisonExist: comparisonExist,
monthComparisonExist: monthComparisonText.length > 0,
monthComparisonText: monthComparisonText,
yearComparisonExist: yearComparisonText.length > 0,
......@@ -281,7 +283,9 @@ const monthlyReportNotification = async ({
previousYear: date.year - 1,
currentYear: date.year,
previousMonthYear: date.month === 1 ? date.year - 1 : date.year,
consoImageUrl: baseUrl + '/assets/multifluidConsumption.png',
consoImageUrl: comparisonExist
? baseUrl + '/assets/multifluidConsumption.png'
: baseUrl + '/assets/multifluidNoConsumption.png',
feedbackImageUrl: baseUrl + '/assets/feedback.png',
})
......