admin/api: use gorilla/mux instead of Go router
This commit is contained in:
parent
3e74f5f9ef
commit
173dafa69e
18 changed files with 643 additions and 720 deletions
|
|
@ -1,43 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
type statsTheme struct {
|
||||
SolvedByLevel []int `json:"solvedByLevel"`
|
||||
}
|
||||
|
||||
type stats struct {
|
||||
Themes map[string]statsTheme `json:"themes"`
|
||||
TryRank []int64 `json:"tryRank"`
|
||||
}
|
||||
|
||||
func genStats() (interface{}, error) {
|
||||
ret := map[string]statsTheme{}
|
||||
|
||||
if themes, err := fic.GetThemes(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
for _, theme := range themes {
|
||||
if exercices, err := theme.GetExercices(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
exos := map[string]fic.ExportedExercice{}
|
||||
for _, exercice := range exercices {
|
||||
exos[fmt.Sprintf("%d", exercice.Id)] = fic.ExportedExercice{
|
||||
exercice.Title,
|
||||
exercice.Gain,
|
||||
exercice.SolvedCount(),
|
||||
exercice.TriedTeamCount(),
|
||||
}
|
||||
}
|
||||
ret[fmt.Sprintf("%d", theme.Id)] = statsTheme{}
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
}
|
||||
Reference in a new issue