display logs with latest first
This commit is contained in:
parent
be53de7326
commit
5d9533b7b4
1 changed files with 3 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ const db = require('./db')
|
|||
const pgp = require('pg-promise')()
|
||||
|
||||
const getMachineName = require('./machine-loader').getMachineName
|
||||
const NUM_RESULTS = 1000
|
||||
const NUM_RESULTS = 500
|
||||
|
||||
/**
|
||||
* Get the latest log's timestamp
|
||||
|
|
@ -62,7 +62,7 @@ function getUnlimitedMachineLogs (deviceId, until = new Date().toISOString()) {
|
|||
where device_id=$1
|
||||
and timestamp <= $2
|
||||
and timestamp > ($2 - interval '2 days')
|
||||
order by timestamp asc, serial asc`
|
||||
order by timestamp desc, serial desc`
|
||||
|
||||
return Promise.all([db.any(sql, [ deviceId, until ]), getMachineName(deviceId)])
|
||||
.then(([logs, machineName]) => ({
|
||||
|
|
@ -75,7 +75,7 @@ function getMachineLogs (deviceId, until = new Date().toISOString()) {
|
|||
const sql = `select id, log_level, timestamp, message from logs
|
||||
where device_id=$1
|
||||
and timestamp <= $3
|
||||
order by timestamp asc, serial asc
|
||||
order by timestamp desc, serial desc
|
||||
limit $2`
|
||||
|
||||
return Promise.all([db.any(sql, [ deviceId, NUM_RESULTS, until ]), getMachineName(deviceId)])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue