From 76ca90d7a661d6d9813b3c410d68f157b315fd9d Mon Sep 17 00:00:00 2001 From: Hugo NOUTS <hnouts@grandlyon.com> Date: Thu, 12 Jan 2023 15:36:25 +0000 Subject: [PATCH] fix(conso): When consulting grdf charts on week or month timestep, last month day or week day was missing data. --- src/services/queryRunner.service.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/services/queryRunner.service.ts b/src/services/queryRunner.service.ts index 044708f40..b9fffafff 100644 --- a/src/services/queryRunner.service.ts +++ b/src/services/queryRunner.service.ts @@ -111,25 +111,29 @@ export default class QueryRunner { timePeriod: TimePeriod, timeStep: TimeStep ) { - // increase timeperiod range because the last data for a day is actually stored the next day at 00:00 if (timeStep === TimeStep.HALF_AN_HOUR) { + // increase timeperiod range because the last data for a day is actually stored the next day at 00:00 timePeriod.startDate = timePeriod.startDate.plus({ minutes: 30 }) timePeriod.endDate = timePeriod.endDate.plus({ minutes: 30 }) } - const filteredResult = data.data.filter((entry: any) => - this.withinDateBoundaries( + + const filteredResult = data.data.filter((entry: any) => { + // added ternary expression to not send to withinDateBoundaries an hour different than zero when not in half-hour mode + const hour = timeStep === TimeStep.HALF_AN_HOUR ? entry.hour : 0 + const min = timeStep === TimeStep.HALF_AN_HOUR ? entry.minute : 0 + return this.withinDateBoundaries( DateTime.local( entry.year, entry.month || 1, entry.day || 1, - entry.hour, - entry.minute + hour, + min ).setZone('utc', { keepLocalTime: true, }), timePeriod ) - ) + }) return filteredResult } -- GitLab