admin: add exercices stats accordion
This commit is contained in:
parent
f4c74f57d6
commit
b387f011d8
3 changed files with 41 additions and 0 deletions
|
@ -22,6 +22,8 @@ func init() {
|
|||
router.PATCH("/api/exercices/:eid", apiHandler(exerciceHandler(partUpdateExercice)))
|
||||
router.DELETE("/api/exercices/:eid", apiHandler(exerciceHandler(deleteExercice)))
|
||||
|
||||
router.GET("/api/exercices/:eid/stats.json", apiHandler(exerciceHandler(getExerciceStats)))
|
||||
|
||||
router.GET("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(getExerciceHistory)))
|
||||
router.PATCH("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(updateExerciceHistory)))
|
||||
router.DELETE("/api/exercices/:eid/history.json", apiHandler(exerciceHandler(delExerciceHistory)))
|
||||
|
@ -167,6 +169,20 @@ func getExerciceHistory(exercice fic.Exercice, body []byte) (interface{}, error)
|
|||
return exercice.GetHistory()
|
||||
}
|
||||
|
||||
type exerciceStats struct {
|
||||
TeamTries int64 `json:"team_tries"`
|
||||
TotalTries int64 `json:"total_tries"`
|
||||
SolvedCount int64 `json:"solved_count"`
|
||||
}
|
||||
|
||||
func getExerciceStats(e fic.Exercice, body []byte) (interface{}, error) {
|
||||
return exerciceStats{
|
||||
TeamTries: e.TriedTeamCount(),
|
||||
TotalTries: e.TriedCount(),
|
||||
SolvedCount: e.SolvedCount(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type uploadedExerciceHistory struct {
|
||||
IdTeam int64 `json:"team_id"`
|
||||
Kind string
|
||||
|
|
Reference in a new issue