change the way themes are stored in stats

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

View File

@ -480,7 +480,11 @@ angular.module("FICApp")
$scope.teamstats = TeamStats.get({ teamId: $routeParams.teamId });
$scope.teamstats.$promise.then(function(res) {
solvedByLevelPie("#pieLevels", res.levels);
solvedByThemesPie("#pieThemes", res.themes);
var themes = [];
angular.forEach(res.themes, function(theme, tid) {
themes.push(theme);
})
solvedByThemesPie("#pieThemes", themes);
});
})
.controller("TeamExercicesController", function($scope, Teams, Themes, TeamMy, Exercice, $routeParams) {

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