qa: Add multiple color on home page
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
nemunaire 2020-09-09 21:17:09 +02:00
commit 95ca255d75
3 changed files with 38 additions and 4 deletions

View file

@ -10,11 +10,38 @@ import (
)
func init() {
router.GET("/api/qa_exercices.json", apiHandler(getExerciceTested))
router.GET("/api/qa_mywork.json", apiHandler(getQAWork))
router.GET("/api/qa_work.json", apiHandler(getQATodo))
router.POST("/api/qa_work.json", apiHandler(createQATodo))
}
type exerciceTested map[int64]string
func getExerciceTested(u QAUser, ps httprouter.Params, body []byte) (interface{}, error) {
if team, err := fic.GetTeam(u.TeamId); err != nil {
return nil, err
} else if exercices, err := fic.GetExercices(); err != nil {
return nil, err
} else {
ret := exerciceTested{}
for _, exercice := range exercices {
if team.HasAccess(exercice) {
if ok, _ := team.HasSolved(exercice); ok {
ret[exercice.Id] = "solved"
} else if cnt, _ := team.CountTries(exercice); cnt > 0 {
ret[exercice.Id] = "tried"
} else {
ret[exercice.Id] = "access"
}
}
}
return ret, nil
}
}
func getQAWork(u QAUser, ps httprouter.Params, body []byte) (interface{}, error) {
if team, err := fic.GetTeam(u.TeamId); err != nil {
return nil, err