give lamassu support 2 full days of logs; log sharing last for 1 week

This commit is contained in:
Josh Harvey 2017-12-15 02:21:59 +02:00
parent dc2f4e497f
commit 783b85ed72
3 changed files with 22 additions and 18 deletions

View file

@ -31,7 +31,7 @@ function get (id) {
* @returns {object} Newly created support_log
*/
function insert (deviceId) {
const sql = `insert into support_logs
const sql = `insert into support_logs
(id, device_id) values ($1, $2) returning *`
return db.one(sql, [uuid.v4(), deviceId])
.then(_.mapKeys(_.camelCase))
@ -49,7 +49,7 @@ function insert (deviceId) {
function batch () {
const sql = `select s.id, s.device_id, s.timestamp, devices.name from support_logs as s
inner join devices on s.device_id = devices.device_id
where timestamp > (now() - interval '2 days')
where timestamp > (now() - interval '1 week')
order by s.timestamp desc`
return db.any(sql)
.then(_.map(_.mapKeys(_.camelCase)))