From 020b180d80959713827ca6fc8dcf1aac71f735a7 Mon Sep 17 00:00:00 2001 From: Filip Leitner Date: Fri, 24 May 2024 10:24:57 +0200 Subject: [PATCH] fix(sensors): aggregations- minimum --- .../src/components/sensors/unit-dialog.service.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/hslayers-sensors/src/components/sensors/unit-dialog.service.ts b/projects/hslayers-sensors/src/components/sensors/unit-dialog.service.ts index 30c40bc6d6..bd3eda4aad 100644 --- a/projects/hslayers-sensors/src/components/sensors/unit-dialog.service.ts +++ b/projects/hslayers-sensors/src/components/sensors/unit-dialog.service.ts @@ -593,7 +593,6 @@ export class HsSensorsUnitDialogService { unit: HsSensorUnit, observations: any, ): Aggregate[] { - // Create a map of sensor IDs to their observations // Create a map of sensor IDs to their observations const observationMap = new Map(); observations.forEach((obs: {sensor_id: string; value: number}) => { @@ -609,7 +608,7 @@ export class HsSensorsUnitDialogService { const observationsForSensor = observationMap.get(sensor.sensor_id as string) || []; const tmp: Aggregate = { - min: 0, + min: undefined, max: 0, avg: 0, sensor_id: sensor.sensor_id, @@ -621,7 +620,7 @@ export class HsSensorsUnitDialogService { let sum = 0; observationsForSensor.forEach((value) => { - if (value < tmp.min) { + if (value < tmp.min || !tmp.min) { tmp.min = value; } if (value > tmp.max) {