change the way themes are stored in stats
This commit is contained in:
parent
2e0e18d577
commit
cc1e7f9e7a
@ -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) {
|
||||
|
@ -14,7 +14,7 @@ type statLine struct {
|
||||
|
||||
type teamStats struct {
|
||||
Levels []statLine `json:"levels"`
|
||||
Themes []statLine `json:"themes"`
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user