refactor: sql formatting and label rename
This commit is contained in:
parent
1a166bc279
commit
00875f06e8
4 changed files with 9 additions and 19 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue