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
@@ -0,0 +1,15 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// trimPercent cuts v to digits decimals instead of rounding, so 99.9996
|
||||
// never reads as a perfect 100. The epsilon absorbs float noise such as
|
||||
// 99.12 being stored as 99.1199999.
|
||||
func trimPercent(v float64, digits int) string {
|
||||
scale := math.Pow(10, float64(digits))
|
||||
v = math.Floor(v*scale+1e-6) / scale
|
||||
return strconv.FormatFloat(v, 'f', digits, 64) + "%"
|
||||
}
|
||||
Reference in new issue
Block a user