Update last_online device field on each machine ping (#203)
* update last_online device field on each machine ping * change var name to camel-case * Use pgp name parameters instead of interpolation
This commit is contained in:
parent
12c834469c
commit
272127518d
1 changed files with 8 additions and 2 deletions
|
|
@ -231,14 +231,20 @@ function plugins (settings, deviceId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function recordPing (serialNumber, deviceTime, rec) {
|
function recordPing (serialNumber, deviceTime, rec) {
|
||||||
const r = {
|
const machinePings = {
|
||||||
id: uuid.v4(),
|
id: uuid.v4(),
|
||||||
device_id: deviceId,
|
device_id: deviceId,
|
||||||
serial_number: serialNumber,
|
serial_number: serialNumber,
|
||||||
device_time: deviceTime
|
device_time: deviceTime
|
||||||
}
|
}
|
||||||
|
const devices = {
|
||||||
|
last_online: deviceTime
|
||||||
|
}
|
||||||
|
|
||||||
return db.none(pgp.helpers.insert(r, null, 'machine_pings'))
|
return Promise.all([
|
||||||
|
db.none(pgp.helpers.insert(machinePings, null, 'machine_pings')),
|
||||||
|
db.none(pgp.helpers.update(devices, null, 'devices') + 'WHERE device_id = ${deviceId}', { deviceId })
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
function isHd (tx) {
|
function isHd (tx) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue