Truncate/trim server tables

This commit is contained in:
Rafael Taranto 2019-04-24 23:05:39 -03:00 committed by Josh Harvey
parent 4640b4a774
commit 67919892e8
5 changed files with 35 additions and 17 deletions

View file

@ -42,12 +42,10 @@ exports.machineEvent = function machineEvent (rec) {
const values = [rec.id, rec.deviceId, rec.eventType, rec.note, rec.deviceTime]
const deleteSql = `delete from machine_events
where device_id=$1
and event_type=$2
and created < now() - interval '2 days'`
where created < now() - interval '1 days'`
return db.none(sql, values)
.then(() => db.none(deleteSql, [rec.deviceId, rec.eventType]))
.then(() => db.none(deleteSql))
}
exports.machineEvents = function machineEvents () {