Too much things
This commit is contained in:
parent
d35bdca3b1
commit
f3a15b00e9
15 changed files with 640 additions and 17 deletions
43
admin/api_stats.go
Normal file
43
admin/api_stats.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
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]exportedExercice{}
|
||||
for _, exercice := range exercices {
|
||||
exos[fmt.Sprintf("%d", exercice.Id)] = exportedExercice{
|
||||
exercice.Title,
|
||||
exercice.Gain,
|
||||
exercice.SolvedCount(),
|
||||
exercice.TriedTeamCount(),
|
||||
}
|
||||
}
|
||||
ret[fmt.Sprintf("%d", theme.Id)] = statsTheme{}
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
}
|
Reference in a new issue