mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-11 00:30:54 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e874b5db18 | ||
|
|
23e7d97e3c | ||
|
|
a222de2c55 |
No files matched your search
+4
-1
@@ -111,7 +111,10 @@ func GetAs[T any](key string, defaul ...any) (T, error) {
|
||||
err := db.First(&item, "key = ?", key).Error
|
||||
if err != nil {
|
||||
if len(defaul) > 0 {
|
||||
v := defaul[0].(T)
|
||||
v, ok := defaul[0].(T)
|
||||
if !ok {
|
||||
return t, fmt.Errorf("default value type mismatch: expected %T, got %T", t, defaul[0])
|
||||
}
|
||||
err = Set(key, v)
|
||||
return v, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package notifier
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -26,10 +27,9 @@ func CheckTraffic() {
|
||||
if len(reports) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := config.GetAs[float64](config.TrafficLimitPercentageKey, 0)
|
||||
cfg, err := config.GetAs[float64](config.TrafficLimitPercentageKey, 80.0)
|
||||
if err != nil {
|
||||
return
|
||||
slog.Error("failed to get traffic limit percentage", "error", err)
|
||||
}
|
||||
|
||||
if cfg <= 0 {
|
||||
|
||||
Reference in new issue
Block a user