change the way themes are stored in stats

This commit is contained in:
nemunaire 2017-01-24 02:17:21 +01:00
commit cc1e7f9e7a
2 changed files with 13 additions and 6 deletions

View file

@ -13,8 +13,8 @@ type statLine struct {
}
type teamStats struct {
Levels []statLine `json:"levels"`
Themes []statLine `json:"themes"`
Levels []statLine `json:"levels"`
Themes map[int64]statLine `json:"themes"`
}
func (s *teamStats) GetLevel(level int) *statLine {
@ -38,7 +38,10 @@ func (t Team) GetStats() (interface{}, error) {
}
func GetTeamsStats(t *Team) (interface{}, error) {
stat := teamStats{}
stat := teamStats{
[]statLine{},
map[int64]statLine{},
}
if themes, err := GetThemes(); err != nil {
return nil, err
@ -84,13 +87,13 @@ func GetTeamsStats(t *Team) (interface{}, error) {
}
}
stat.Themes = append(stat.Themes, statLine{
stat.Themes[theme.Id] = statLine{
theme.Name,
total,
solved,
tried,
tries,
})
}
}
return stat, nil