From b051030b06ba2cf26f14a39e04376a5c8a31e653 Mon Sep 17 00:00:00 2001 From: hnouts <hnouts@grandlyon.com> Date: Wed, 21 Jun 2023 11:37:55 +0200 Subject: [PATCH] oups --- src/services/profileType.service.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/services/profileType.service.ts b/src/services/profileType.service.ts index f911b87f8..37a9369d1 100644 --- a/src/services/profileType.service.ts +++ b/src/services/profileType.service.ts @@ -507,21 +507,34 @@ export default class ProfileTypeService { .endOf('month') .plus({ minutes: 5 }) .toISO() + console.log('MY DATE : ', startDate, endDate) // We add or remove 5 minutes so the api returns the exact period try { const result = await this._client .getStackClient() .fetchJSON( 'GET', - `/remote/org.ecolyo.dju?observedProperty=degreeDay&startDate=${startDate}&endDate=${endDate}` + `/remote/org.ecolyo.dju_v2?startDate=${startDate}&endDate=${endDate}` ) - let monthDju = 0 + const monthDju = 0 if (result) { - for (const observation of result.observations) { - monthDju += observation.result.value + const degreeDayObservations = result.values.filter( + value => value.observation === 'degreeDay' + ) + let monthDju = 0 + + for (const observation of degreeDayObservations) { + monthDju += observation.measurement + } + + if (monthDju === 0) { + return heatingData.dju_average_by_month[month - 1] + } else { + return monthDju } } + console.log('DJU MONTH : ', monthDju) if (monthDju === 0) { return heatingData.dju_average_by_month[month - 1] } else { -- GitLab