fix support log bug

This commit is contained in:
Josh Harvey 2018-07-17 18:02:42 +03:00
parent dcef083d49
commit fe45967274
2 changed files with 212 additions and 281 deletions

View file

@ -58,10 +58,12 @@ function update (deviceId, logLines) {
}
function getUnlimitedMachineLogs (deviceId, until = new Date().toISOString()) {
// Note: sql is a little confusing here, since timestamp is used both as a column
// and a reserved word, but it works.
const sql = `select id, log_level, timestamp, message from logs
where device_id=$1
and timestamp <= $2
and timestamp > ($2 - interval '2 days')
and timestamp > (timestamp $2 - interval '2 days')
order by timestamp desc, serial desc`
return Promise.all([db.any(sql, [ deviceId, until ]), getMachineName(deviceId)])