chore: simplify some steps (#912)

This commit is contained in:
UUBulb
2024-12-25 20:24:13 +08:00
committed by GitHub
parent 6cf0e7f1cf
commit 7d15838548
2 changed files with 12 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ import (
"sync"
"github.com/nezhahq/nezha/model"
"github.com/nezhahq/nezha/pkg/utils"
)
var (
@@ -45,10 +46,7 @@ func BlockByIPs(ipList []string) error {
func GetOnlineUsers(limit, offset int) []*model.OnlineUser {
OnlineUserMapLock.Lock()
defer OnlineUserMapLock.Unlock()
var users []*model.OnlineUser
for _, user := range OnlineUserMap {
users = append(users, user)
}
users := utils.MapValuesToSlice(OnlineUserMap)
slices.SortFunc(users, func(i, j *model.OnlineUser) int {
return i.ConnectedAt.Compare(j.ConnectedAt)
})