refactor: use the built-in max/min to simplify the code (#5751)
Some checks are pending
CI / go-test (push) Waiting to run
CI / codegen (push) Waiting to run
CI / govulncheck (push) Waiting to run
CI / race (push) Waiting to run
CI / fuzz-smoke (push) Waiting to run
CI / golangci (push) Waiting to run
CI / frontend (push) Waiting to run
CodeQL Advanced / Analyze (go) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Release 3X-UI / Build for Windows (push) Waiting to run
Release 3X-UI / Publish rolling dev release (push) Blocked by required conditions

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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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 {