Skip to content

Commit

Permalink
Short circuit if falsey to prevent getValue error
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrogers committed Sep 27, 2023
1 parent c89a3fb commit 9a7ea0a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/providers/fault-mgmt-providers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ function faultModelConvertor(faultData, type) {
console.log('current', faultData?.parameterDetail?.currentValue);
console.log('trigger', faultData?.parameterDetail?.triggerValue);

const currentValue = getValue(faultData?.parameterDetail?.currentValue);
const triggerValue = getValue(faultData?.parameterDetail?.triggerValue);
const currentValue = faultData?.parameterDetail?.currentValue && getValue(faultData.parameterDetail.currentValue);
const triggerValue = faultData?.parameterDetail?.triggerValue && getValue(faultData?.parameterDetail?.triggerValue);
console.log({currentValue, triggerValue});

return {
type: type || faultData?.type,
fault: {
acknowledged: Boolean(faultData?.acknowledged),
currentValueInfo: {
value: getValue(faultData?.parameterDetail?.currentValue),
value: currentValue,
rangeCondition: faultData?.parameterDetail?.currentValue?.rangeCondition,
monitoringResult: faultData?.parameterDetail?.currentValue?.monitoringResult
},
Expand All @@ -49,7 +49,7 @@ function faultModelConvertor(faultData, type) {
shortDescription: faultData?.parameterDetail?.parameter?.shortDescription,
triggerTime: faultData?.triggerTime,
triggerValueInfo: {
value: getValue(faultData?.parameterDetail?.triggerValue),
value: triggerValue,
rangeCondition: faultData?.parameterDetail?.triggerValue?.rangeCondition,
monitoringResult: faultData?.parameterDetail?.triggerValue?.monitoringResult
}
Expand Down

0 comments on commit 9a7ea0a

Please sign in to comment.