diff --git a/src/services/profileType.service.ts b/src/services/profileType.service.ts index f911b87f894a6ae38c19496dff57d6ab13bd4ef1..37a9369d190e48a953002b94d49cfa6d6ba178c4 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 {