Skip to content

Commit

Permalink
fix(sensors): aggregations- minimum
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipLeitner committed Jun 10, 2024
1 parent 22fd160 commit 020b180
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, number[]>();
observations.forEach((obs: {sensor_id: string; value: number}) => {
Expand All @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 020b180

Please sign in to comment.