challenge-sync-airbus: Refactor and prefer calling it cyberrange

This commit is contained in:
nemunaire 2025-03-25 17:58:16 +01:00
commit cb4ceecbf5
6 changed files with 46 additions and 37 deletions

View file

@ -2,27 +2,12 @@ package main
import (
"fmt"
"srs.epita.fr/fic-server/libfic"
)
type AirbusTeam struct {
UUID string `json:"session_uuid"`
Members []TeamMember `json:"members"`
Name string `json:"name"`
Score int64 `json:"score"`
Rank int `json:"rank"`
}
type TeamMember struct {
UUID string `json:"session_uuid"`
Name string `json:"name"`
Nickname string `json:"nickname"`
EMail string `json:"email"`
}
type airbusDataTeam []AirbusTeam
func (a *AirbusAPI) GetTeams() ([]AirbusTeam, error) {
var data airbusDataTeam
func (a *AirbusAPI) GetTeams() ([]fic.CyberrangeTeam, error) {
var data []fic.CyberrangeTeam
err := a.request("GET", fmt.Sprintf("/v1/sessions/%s/teams", a.SessionUUID), nil, &data)
if err != nil {
return nil, err
@ -31,13 +16,13 @@ func (a *AirbusAPI) GetTeams() ([]AirbusTeam, error) {
}
}
type ByRank []*AirbusTeam
type ByRank []*fic.CyberrangeTeam
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
type ByScore []*fic.CyberrangeTeam
func (a ByScore) Len() int { return len(a) }
func (a ByScore) Swap(i, j int) { a[i], a[j] = a[j], a[i] }