fix: show the correct status for each machine
This commit is contained in:
parent
e9f033d915
commit
7c926675f9
2 changed files with 11 additions and 13 deletions
|
|
@ -60,7 +60,7 @@ function addName (pings, events, config) {
|
||||||
const statuses = [
|
const statuses = [
|
||||||
getStatus(
|
getStatus(
|
||||||
_.first(pings[machine.deviceId]),
|
_.first(pings[machine.deviceId]),
|
||||||
_.first(checkStuckScreen(events, machine.name))
|
_.first(checkStuckScreen(events, machine))
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,8 @@ function buildAlerts (pings, balances, events, devices) {
|
||||||
alerts.general = _.filter(r => !r.deviceId, balances)
|
alerts.general = _.filter(r => !r.deviceId, balances)
|
||||||
_.forEach(device => {
|
_.forEach(device => {
|
||||||
const deviceId = device.deviceId
|
const deviceId = device.deviceId
|
||||||
const deviceName = device.name
|
|
||||||
const deviceEvents = events.filter(function (eventRow) {
|
|
||||||
return eventRow.device_id === deviceId
|
|
||||||
})
|
|
||||||
const ping = pings[deviceId] || []
|
const ping = pings[deviceId] || []
|
||||||
const stuckScreen = checkStuckScreen(deviceEvents, deviceName)
|
const stuckScreen = checkStuckScreen(events, device)
|
||||||
|
|
||||||
alerts.devices = _.set([deviceId, 'balanceAlerts'], _.filter(
|
alerts.devices = _.set([deviceId, 'balanceAlerts'], _.filter(
|
||||||
['deviceId', deviceId],
|
['deviceId', deviceId],
|
||||||
|
|
@ -97,7 +93,7 @@ function buildAlerts (pings, balances, events, devices) {
|
||||||
), alerts.devices)
|
), alerts.devices)
|
||||||
alerts.devices[deviceId].deviceAlerts = _.isEmpty(ping) ? stuckScreen : ping
|
alerts.devices[deviceId].deviceAlerts = _.isEmpty(ping) ? stuckScreen : ping
|
||||||
|
|
||||||
alerts.deviceNames[deviceId] = deviceName
|
alerts.deviceNames[deviceId] = device.name
|
||||||
}, devices)
|
}, devices)
|
||||||
|
|
||||||
return alerts
|
return alerts
|
||||||
|
|
@ -109,12 +105,13 @@ function checkPings (devices) {
|
||||||
return _.zipObject(deviceIds)(pings)
|
return _.zipObject(deviceIds)(pings)
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkStuckScreen (deviceEvents, machineName) {
|
function checkStuckScreen (deviceEvents, machine) {
|
||||||
const sortedEvents = _.sortBy(
|
const lastEvent = _.pipe(
|
||||||
utils.getDeviceTime,
|
_.filter(e => e.device_id === machine.deviceId),
|
||||||
_.map(utils.parseEventNote, deviceEvents)
|
_.sortBy(utils.getDeviceTime),
|
||||||
)
|
_.map(utils.parseEventNote),
|
||||||
const lastEvent = _.last(sortedEvents)
|
_.last
|
||||||
|
)(deviceEvents)
|
||||||
|
|
||||||
if (!lastEvent) return []
|
if (!lastEvent) return []
|
||||||
|
|
||||||
|
|
@ -124,6 +121,7 @@ function checkStuckScreen (deviceEvents, machineName) {
|
||||||
if (isIdle) return []
|
if (isIdle) return []
|
||||||
|
|
||||||
const age = Math.floor(lastEvent.age)
|
const age = Math.floor(lastEvent.age)
|
||||||
|
const machineName = machine.name
|
||||||
if (age > STALE_STATE) return [{ code: STALE, state, age, machineName }]
|
if (age > STALE_STATE) return [{ code: STALE, state, age, machineName }]
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue