From 7136b827d3147effde81e93d2d371dac01cdbb8a Mon Sep 17 00:00:00 2001 From: osmarks Date: Thu, 28 Jan 2021 22:29:17 +0000 Subject: [PATCH] make uptimeSince actually filter by timestamps --- src/onstat.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/onstat.nim b/src/onstat.nim index 017fc1a..665914f 100644 --- a/src/onstat.nim +++ b/src/onstat.nim @@ -56,8 +56,8 @@ type uptimePercent: float proc uptimeSince(sid: int, time: Time): float = - let okPings = fromDbValue(get getDB().value("SELECT COUNT(*) FROM reqs WHERE site = ? AND status <= 0", sid), int) - let totalPings = fromDbValue(get getDB().value("SELECT COUNT(*) FROM reqs WHERE site = ?", sid), int) + let okPings = fromDbValue(get getDB().value("SELECT COUNT(*) FROM reqs WHERE site = ? AND status <= 0 AND timestamp >= ?", sid, time), int) + let totalPings = fromDbValue(get getDB().value("SELECT COUNT(*) FROM reqs WHERE site = ? AND timestamp >= ?", sid, time), int) okPings / totalPings proc fetchLatest(row: ResultRow): Option[SiteStatus] =