Optimize machine pings query (#222)

* refactor recordPing method

* optimize queries

* migrate machine_pings

remove id, serial_number
add primary key on device_id
add unique constraint on device_id

* remove filelds from query, rename migration, delete duplicate migration

* truncate machine_pings in migration
This commit is contained in:
Zoran Joka 2018-11-21 11:08:19 +01:00 committed by Josh Harvey
parent e7bb29341d
commit 13040f41a1
3 changed files with 22 additions and 12 deletions

View file

@ -130,9 +130,7 @@ function checkStuckScreen (deviceEvents) {
function checkPing (deviceId) {
const sql = `select (EXTRACT(EPOCH FROM (now() - created))) * 1000 AS age from machine_pings
where device_id=$1
order by created desc
limit 1`
where device_id=$1`
return db.oneOrNone(sql, [deviceId])
.then(row => {