format for latest standard
This commit is contained in:
parent
4108efd9c7
commit
c2af183911
77 changed files with 1697 additions and 1693 deletions
20
lib/logs.js
20
lib/logs.js
|
|
@ -22,7 +22,7 @@ function getLastSeen (deviceId) {
|
|||
where device_id=$1
|
||||
order by timestamp desc, serial desc limit 1`
|
||||
return db.oneOrNone(sql, [deviceId])
|
||||
.then(log => log ? {timestamp: log.timestamp, serial: log.serial, id: log.id} : null)
|
||||
.then(log => log ? {timestamp: log.timestamp, serial: log.serial, id: log.id} : null)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +40,7 @@ function getLastSeen (deviceId) {
|
|||
function update (deviceId, logLines) {
|
||||
const cs = new pgp.helpers.ColumnSet([
|
||||
'id', 'device_id', 'log_level', 'timestamp', 'serial', 'message'],
|
||||
{table: 'logs'})
|
||||
{table: 'logs'})
|
||||
|
||||
const logs = _.map(log => {
|
||||
const formatted = {
|
||||
|
|
@ -65,10 +65,10 @@ function getUnlimitedMachineLogs (deviceId, until = new Date().toISOString()) {
|
|||
order by timestamp asc, serial asc`
|
||||
|
||||
return Promise.all([db.any(sql, [ deviceId, until ]), getMachineName(deviceId)])
|
||||
.then(([logs, machineName]) => ({
|
||||
logs: _.map(_.mapKeys(_.camelCase), logs),
|
||||
currentMachine: {deviceId, name: machineName}
|
||||
}))
|
||||
.then(([logs, machineName]) => ({
|
||||
logs: _.map(_.mapKeys(_.camelCase), logs),
|
||||
currentMachine: {deviceId, name: machineName}
|
||||
}))
|
||||
}
|
||||
|
||||
function getMachineLogs (deviceId, until = new Date().toISOString()) {
|
||||
|
|
@ -79,10 +79,10 @@ function getMachineLogs (deviceId, until = new Date().toISOString()) {
|
|||
limit $2`
|
||||
|
||||
return Promise.all([db.any(sql, [ deviceId, NUM_RESULTS, until ]), getMachineName(deviceId)])
|
||||
.then(([logs, machineName]) => ({
|
||||
logs: _.map(_.mapKeys(_.camelCase), logs),
|
||||
currentMachine: {deviceId, name: machineName}
|
||||
}))
|
||||
.then(([logs, machineName]) => ({
|
||||
logs: _.map(_.mapKeys(_.camelCase), logs),
|
||||
currentMachine: {deviceId, name: machineName}
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports = { getUnlimitedMachineLogs, getMachineLogs, update, getLastSeen }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue