support for specifiyng host

This commit is contained in:
cupcakearmy 2020-09-20 17:43:39 +02:00
parent 88ebc6b5dd
commit 45d09a41ce
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9

View File

@ -5,14 +5,17 @@ import { Logs } from '../shared/db'
export async function data({ start, end }) { export async function data({ start, end }) {
const logs = await getLogsBetweenDates({ start, end }) const logs = await getLogsBetweenDates({ start, end })
console.log('Found', logs.length)
return groupBy(logs, 'host') return groupBy(logs, 'host')
} }
export async function getLogsBetweenDates({ start, end }) { export async function getLogsBetweenDates({ start, end, host }) {
return await Logs.find({ const where = {
$and: [{ timestamp: { $gt: start } }, { timestamp: { $lt: end } }], $and: [{ timestamp: { $gt: start } }, { timestamp: { $lt: end } }],
}) }
console.log(host)
if (host) where.host = host
console.log('Where', where)
return await Logs.find(where)
} }
export function countInGroup(grouped) { export function countInGroup(grouped) {