feat(web): switch charts between 1h, 3h, 12h, 24h and 7d with matching SLA
Bars use a resolution fitting the range and the latency line is placed by time. The SLA is the share of time a monitor was not down, counted from incidents and only since the monitor exists. Monitor pages list the SLA from one hour to 90 days. Closes #59 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
b210c8e5c0
commit
273a958d76
11 files changed
+1419
-810
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -31,3 +32,15 @@ func TestPercent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLatencyPlacesPointsByTime(t *testing.T) {
|
||||
from := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
to := from.Add(10 * time.Minute)
|
||||
l := Latency([]Bucket{
|
||||
{Start: from.Add(5 * time.Minute), Total: 1, Latency: 100},
|
||||
{Start: from.Add(10 * time.Minute), Total: 1, Latency: 50},
|
||||
}, from, to, 100, 10)
|
||||
if !strings.HasPrefix(l.Points, "50.0,") || !strings.Contains(l.Points, " 100.0,") {
|
||||
t.Errorf("Latency().Points = %q, want points at x=50 and x=100", l.Points)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user