This commit is contained in:
Josh Harvey 2016-10-24 01:55:17 +03:00
parent 594228e871
commit defb8d0f34
7 changed files with 36 additions and 53 deletions

View file

@ -36,8 +36,8 @@ function checkBalance (rec) {
}
function checkBalances () {
var balances = getBalances()
return R.reject(R.isNil, balances.map(checkBalance))
return getBalances()
.then(balances => R.reject(R.isNil, balances.map(checkBalance)))
}
function checkPing (deviceEvents) {
@ -87,13 +87,13 @@ function devicesAndEvents () {
function checkStatus () {
var alerts = {devices: {}, deviceNames: {}}
alerts.general = checkBalances()
return devicesAndEvents()
.then(function (rec) {
return Promise.all([checkBalances(), devicesAndEvents()])
.then(([balances, rec]) => {
var devices = rec.devices
var events = rec.events
alerts.general = balances
devices.forEach(function (deviceRow) {
var deviceId = deviceRow.device_id
var deviceName = deviceRow.name || deviceId