There is a task to count the number of words "not_available", if 12 then send 1, if at least one of them is "available" send 0
Below is a sample code that still sends 0 even if the number of "not_available" = 12
What was I wrong about?
var Count_available = (rootObj.match(/AVAILABLE/g) || []).length
var Count_unavailable = (rootObj.match(/NOT_AVAILABLE/g) || []).length
if (Count_available >= 1) {
var jsondata = {
"type": "SberLogistic.Availability",
"series": [{
"timeseriesId": "custom:syntheticmonitors.availability",
"dimensions": {
"config_id": "CI02874375"
},
"dataPoints": [
[Number(new Date()), 1]
] //send 1
}]
}
} else if (Count_unavailable == 12) {
var jsondata = {
"type": "SberLogistic.Availability",
"series": [{
"timeseriesId": "custom:syntheticmonitors.availability",
"dimensions": {
"config_id": "CI02874375"
},
"dataPoints": [
[Number(new Date()), 0]
] //send 0
}]
}
};