From d9b8a907010608f8db4722996df6434c3f08e671 Mon Sep 17 00:00:00 2001 From: lemmi Date: Thu, 23 Jan 2020 04:17:48 +0100 Subject: [PATCH] improve filtering the noise - filter larger downtimes - for small downtimes sort by counts --- main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 2ea3f74..895591c 100644 --- a/main.go +++ b/main.go @@ -47,7 +47,7 @@ func (r route) Downtime(now time.Time) float64 { } func (r route) Noise(now time.Time) bool { - return r.Counter <= uint(now.Sub(startTime).Hours()) && r.Downtime(now) < 0.1 + return r.Counter <= uint(now.Sub(startTime).Hours())+10 && r.Downtime(now) < 0.5 } func (r route) String() string { @@ -133,7 +133,13 @@ func (rs *routeStats) getLongest() []route { t := time.Now() sort.Slice(ret, func(i, j int) bool { - return ret[i].DurationUntil(t) > ret[j].DurationUntil(t) + id := ret[i].Downtime(t) + jd := ret[j].Downtime(t) + if id == jd || + (id < 0.5 && jd < 0.5) { + return ret[i].Counter > ret[j].Counter + } + return id > jd }) return ret