refactor: sql formatting and label rename

This commit is contained in:
José Oliveira 2021-07-19 14:42:37 +01:00 committed by Josh Harvey
parent 1a166bc279
commit 00875f06e8
4 changed files with 9 additions and 19 deletions

View file

@ -290,19 +290,9 @@ function plugins (settings, deviceId) {
}
function pruneMachinesHeartbeat () {
const sql = `DELETE
FROM
machine_network_heartbeat h
USING (SELECT
device_id,
max(created) as lastEntry
FROM
machine_network_heartbeat
GROUP BY
device_id) d
WHERE
d.device_id = h.device_id
AND h.created < d.lastEntry`
const sql = `DELETE FROM machine_network_heartbeat h
USING (SELECT device_id, max(created) as lastEntry FROM machine_network_heartbeat GROUP BY device_id) d
WHERE d.device_id = h.device_id AND h.created < d.lastEntry`
db.none(sql)
}