Delete machine pings on unpair
This commit is contained in:
parent
8330b95de1
commit
09332c37db
2 changed files with 4 additions and 1 deletions
|
|
@ -229,6 +229,8 @@ function alertSubject (alertRec) {
|
|||
alerts = _.concat(alerts, alertRec.devices[device])
|
||||
})
|
||||
|
||||
if (alerts.length === 0) return null
|
||||
|
||||
const alertTypes = _.map(codeDisplay, _.uniq(_.map('code', alerts))).sort()
|
||||
return '[Lamassu] Errors reported: ' + alertTypes.join(', ')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ function removeDeviceConfig (deviceId) {
|
|||
|
||||
function unpair (deviceId) {
|
||||
const sql = 'delete from devices where device_id=$1'
|
||||
return db.none(sql, [deviceId])
|
||||
const deleteMachinePings = 'delete from machine_pings where device_id=$1'
|
||||
return Promise.all([db.none(sql, [deviceId]), db.none(deleteMachinePings, [deviceId])])
|
||||
.then(() => removeDeviceConfig(deviceId))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue