From 5d9533b7b44ad92c25c06f65dbb96dc550e4835f Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Fri, 18 May 2018 18:19:19 +0300 Subject: [PATCH] display logs with latest first --- lib/logs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/logs.js b/lib/logs.js index ec540cff..7866fa9f 100644 --- a/lib/logs.js +++ b/lib/logs.js @@ -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)])