improve filtering the noise

- filter larger downtimes
- for small downtimes sort by counts
This commit is contained in:
lemmi 2020-01-23 04:17:48 +01:00
parent 05bff7f5ad
commit d9b8a90701
1 changed files with 8 additions and 2 deletions

10
main.go
View File

@ -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