server/remote/challenge-sync-airbus/team.go

47 lines
1.1 KiB
Go
Raw Normal View History

2023-04-06 01:48:52 +00:00
package main
import (
"fmt"
)
type AirbusTeam struct {
ID int64 `json:"id"`
Members []TeamMember `json:"members"`
Name string `json:"name"`
2024-03-19 10:49:39 +00:00
Score int64 `json:"score"`
Rank int `json:"rank"`
2023-04-06 01:48:52 +00:00
}
type TeamMember struct {
ID int64 `json:"id"`
Name string `json:"name"`
Nickname string `json:"nickname"`
EMail string `json:"email"`
}
type airbusDataTeam struct {
Data []AirbusTeam `json:"data"`
}
func (a *AirbusAPI) GetTeams() ([]AirbusTeam, error) {
var data airbusDataTeam
2023-04-06 13:37:05 +00:00
err := a.request("GET", fmt.Sprintf("/v1/sessions/%d/teams", a.SessionID), nil, &data)
2023-04-06 01:48:52 +00:00
if err != nil {
return nil, err
} else {
return data.Data, nil
}
}
2024-03-19 10:49:39 +00:00
type ByRank []*AirbusTeam
func (a ByRank) Len() int { return len(a) }
func (a ByRank) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByRank) Less(i, j int) bool { return a[i].Rank < a[j].Rank }
type ByScore []*AirbusTeam
func (a ByScore) Len() int { return len(a) }
func (a ByScore) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByScore) Less(i, j int) bool { return a[i].Score < a[j].Score }