From 45d09a41ce72a0e398b92a1b0c717cc09a9247df Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sun, 20 Sep 2020 17:43:39 +0200 Subject: [PATCH] support for specifiyng host --- src/dashboard/lib.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dashboard/lib.js b/src/dashboard/lib.js index aedf42c..d795b70 100644 --- a/src/dashboard/lib.js +++ b/src/dashboard/lib.js @@ -5,14 +5,17 @@ import { Logs } from '../shared/db' export async function data({ start, end }) { const logs = await getLogsBetweenDates({ start, end }) - console.log('Found', logs.length) return groupBy(logs, 'host') } -export async function getLogsBetweenDates({ start, end }) { - return await Logs.find({ +export async function getLogsBetweenDates({ start, end, host }) { + const where = { $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) {