Fix check pings query
This commit is contained in:
parent
1a467707e8
commit
15c8e0d862
3 changed files with 15 additions and 2 deletions
|
|
@ -128,7 +128,7 @@ function checkStuckScreen (deviceEvents, machineName) {
|
|||
}
|
||||
|
||||
function checkPing (device) {
|
||||
const sql = `select (EXTRACT(EPOCH FROM (now() - created))) * 1000 AS age from machine_pings
|
||||
const sql = `select (EXTRACT(EPOCH FROM (now() - updated))) * 1000 AS age from machine_pings
|
||||
where device_id=$1`
|
||||
const deviceId = device.deviceId
|
||||
return db.oneOrNone(sql, [deviceId])
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ function plugins (settings, deviceId) {
|
|||
|
||||
return Promise.all([
|
||||
db.none(`insert into machine_pings(device_id, device_time) values($1, $2)
|
||||
ON CONFLICT (device_id) DO UPDATE SET device_time = $2`, [deviceId, deviceTime]),
|
||||
ON CONFLICT (device_id) DO UPDATE SET device_time = $2, updated = now()`, [deviceId, deviceTime]),
|
||||
db.none(pgp.helpers.update(devices, null, 'devices') + 'WHERE device_id = ${deviceId}', {
|
||||
deviceId
|
||||
})
|
||||
|
|
|
|||
13
migrations/1557800959028-machine-pings-rename.js
Normal file
13
migrations/1557800959028-machine-pings-rename.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
const db = require('./db')
|
||||
|
||||
exports.up = function (next) {
|
||||
var sql = [
|
||||
'ALTER TABLE machine_pings RENAME COLUMN created to updated'
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue