This commit is contained in:
Josh Harvey 2016-05-28 22:04:44 +03:00
parent 258a175dc6
commit 316a240130
3 changed files with 59 additions and 70 deletions

View file

@ -81,17 +81,8 @@ function checkStuckScreen (deviceEvents) {
}
function devicesAndEvents () {
return new Promise(function (resolve, reject) {
db.devices(function (err, devices) {
if (err) return reject(err)
db.machineEvents(function (err, events) {
if (err) return reject(err)
return resolve({devices: devices, events: events})
})
})
})
return Promise.all(db.devices, db.machineEvents)
.then(arr => ({devices: arr[0], events: arr[1]}))
}
function checkStatus () {
@ -103,10 +94,10 @@ function checkStatus () {
var devices = rec.devices
var events = rec.events
devices.rows.forEach(function (deviceRow) {
devices.forEach(function (deviceRow) {
var deviceFingerprint = deviceRow.fingerprint
var deviceName = deviceRow.name || deviceFingerprint
var deviceEvents = events.rows.filter(function (eventRow) {
var deviceEvents = events.filter(function (eventRow) {
return eventRow.device_fingerprint === deviceFingerprint
})