From cbf72eedab97f82ed5c4aac7d0dceccb1d383818 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 4 Dec 2022 15:33:51 -0800 Subject: [PATCH] fix missing passing condition --- src/widgets/scrutiny/component.jsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/widgets/scrutiny/component.jsx b/src/widgets/scrutiny/component.jsx index a9919c9d8..00ebe5ede 100644 --- a/src/widgets/scrutiny/component.jsx +++ b/src/widgets/scrutiny/component.jsx @@ -14,16 +14,10 @@ export default function Component({ service }) { // @see https://github.com/AnalogJ/scrutiny/blob/d8d56f77f9e868127c4849dac74d65512db658e8/webapp/frontend/src/app/core/config/app.config.ts const DeviceStatusThreshold = { - smart : 1, + smart: 1, scrutiny: 2, both: 3 } - - const thresholdStatusMapping = new Map([ - [DeviceStatusThreshold.smart, DeviceStatus.failed_smart], - [DeviceStatusThreshold.scrutiny, DeviceStatus.failed_scrutiny], - [DeviceStatusThreshold.both, DeviceStatus.both] - ]) const { widget } = service; @@ -48,9 +42,9 @@ export default function Component({ service }) { const deviceIds = Object.values(scrutinyData.data.summary); const statusThreshold = scrutinySettings.settings.metrics.status_threshold; - const failed = deviceIds.filter(deviceId => [thresholdStatusMapping.get(statusThreshold), DeviceStatus.failed_both].includes(deviceId.device.device_status))?.length || 0; + const failed = deviceIds.filter(deviceId => (deviceId.device.device_status > 0 && statusThreshold === DeviceStatusThreshold.both) || [statusThreshold, DeviceStatus.failed_both].includes(deviceId.device.device_status))?.length || 0; const unknown = deviceIds.filter(deviceId => deviceId.device.device_status < DeviceStatus.passed || deviceId.device.device_status > DeviceStatus.failed_both)?.length || 0; - const passed = deviceIds.filter(deviceId => deviceId.device.device_status === 0)?.length || 0; + const passed = deviceIds.filter(deviceId => deviceId.device.device_status === 0 || (deviceId.device.device_status > statusThreshold && deviceId.device.device_status < DeviceStatus.failed_both))?.length || 0; return (