Write docs!
This commit is contained in:
parent
c460bb7bf5
commit
bcc598ebd5
37 changed files with 478 additions and 188 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// exportedTeam is a structure representing a Team, as exposed to players.
|
||||
type exportedTeam struct {
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
|
|
@ -11,13 +12,17 @@ type exportedTeam struct {
|
|||
Points float64 `json:"score"`
|
||||
}
|
||||
|
||||
func ExportTeams() (interface{}, error) {
|
||||
if teams, err := GetTeams(); err != nil {
|
||||
return nil, err
|
||||
} else if rank, err := GetRank(); err != nil {
|
||||
// Exportedteam creates the structure to respond as teams.json.
|
||||
func ExportTeams() (ret map[string]exportedTeam, err error) {
|
||||
var teams []Team
|
||||
var rank map[int64]int
|
||||
|
||||
if teams, err = GetTeams(); err != nil {
|
||||
return
|
||||
} else if rank, err = GetRank(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
ret := map[string]exportedTeam{}
|
||||
ret = map[string]exportedTeam{}
|
||||
for _, team := range teams {
|
||||
points, _ := team.GetPoints()
|
||||
ret[fmt.Sprintf("%d", team.Id)] = exportedTeam{
|
||||
|
|
@ -28,6 +33,6 @@ func ExportTeams() (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue