mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-07-18 16:51:25 -05:00
API: Allow more advanced group filtering
This commit is contained in:
parent
3337d7fc0d
commit
fbde8963db
|
|
@ -24,8 +24,7 @@ func HandleGroups(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
gameName := query.Get("game")
|
||||
groups := qr2.GetGroups(gameName)
|
||||
groups := qr2.GetGroups(query["game"], query["id"])
|
||||
|
||||
for _, group := range groups {
|
||||
for i, player := range group.Players {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func HandleStats(w http.ResponseWriter, r *http.Request) {
|
|||
stats := map[string]Stats{}
|
||||
|
||||
servers := qr2.GetSessionServers()
|
||||
groups := qr2.GetGroups("")
|
||||
groups := qr2.GetGroups([]string{}, []string{})
|
||||
|
||||
globalStats := Stats{
|
||||
OnlinePlayerCount: len(servers),
|
||||
|
|
|
|||
|
|
@ -238,14 +238,18 @@ type GroupInfo struct {
|
|||
}
|
||||
|
||||
// GetGroups returns an unsorted copy of all online rooms
|
||||
func GetGroups(gameName string) []GroupInfo {
|
||||
func GetGroups(gameNames []string, groupNames []string) []GroupInfo {
|
||||
var groupsCopy []GroupInfo
|
||||
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
||||
for _, group := range groups {
|
||||
if gameName != "" && gameName != group.GameName {
|
||||
if len(gameNames) > 0 && !common.StringInSlice(group.GameName, gameNames) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(groupNames) > 0 && !common.StringInSlice(group.GroupName, groupNames) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user