refactor: use the built-in max/min to simplify the code (#5751)

Signed-off-by: alaningtrump <alaningtrump@outlook.com>
This commit is contained in:
alaningtrump
2026-07-05 06:58:18 +08:00
committed by GitHub
parent b177e30714
commit 07d66aa6dc
+2 -8
View File
@@ -55,14 +55,8 @@ func (s *ClientService) ListGroups() ([]GroupSummary, error) {
}
out := make([]GroupSummary, 0, len(merged))
for name, agg := range merged {
up := agg.up - baseUp[name]
if up < 0 {
up = 0
}
down := agg.down - baseDown[name]
if down < 0 {
down = 0
}
up := max(agg.up-baseUp[name], 0)
down := max(agg.down-baseDown[name], 0)
out = append(out, GroupSummary{Name: name, ClientCount: agg.count, TrafficUsed: up + down, Up: up, Down: down})
}
sort.Slice(out, func(i, j int) bool {