Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/jobs/ipmi-sdr-alert-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,22 @@ function ipmiSdrPollerAlertJobFactory(
alertObj.reading = val;
alertObj.inCondition = true;
alertObj.node = data.node;
conf.inCondition[val['Sensor Id'].replace(/\./ig, '_')] = true;
conf.inCondition[val['Sensor Id']] = true;
results.push(alertObj);

} else if (val.Status === 'ok' && conf.inCondition[val['Sensor Id']]) {
alertObj = _.omit(data, 'sdr');
alertObj.reading = val;
alertObj.inCondition = false;
alertObj.node = data.node;
conf.inCondition[val['Sensor Id'].replace(/\./ig, '_')] = false;

conf.inCondition[val['Sensor Id']] = false;
results.push(alertObj);
}
});

conf.inCondition = _.transform(conf.inCondition, function(result, val, key) {
result[key.replace(/\./ig, '_')] = val;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that we'll end up with redundant un-sanitized keys in the object? Because we're adding a new key but not deleting the old, un-sanitized one. Seems like we would want to start with an empty accumulator object rather than the existing conf.inCondition one (unless I'm reading this wrong).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think you're right. I think it might be worth extracting this transform into a function that can be tested separately.

@VulpesArtificem

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He's right, I misunderstood _.transform().

});
return [alerts, waterline.workitems.update({ id: data.workItemId }, { config: conf })];
})
.spread(function(alerts) {
Expand Down