admin: include coefficient in history.json
This commit is contained in:
parent
60ec9704e3
commit
6a1f73c895
4 changed files with 20 additions and 17 deletions
|
@ -9,12 +9,12 @@ import (
|
|||
func (e Exercice) GetHistory() ([]map[string]interface{}, error) {
|
||||
hist := make([]map[string]interface{}, 0)
|
||||
|
||||
if rows, err := DBQuery(`SELECT id_team, U.name, U.color, "tries" AS kind, time, id_exercice, NULL, NULL FROM exercice_tries NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "solved" AS kind, time, id_exercice, coefficient, NULL FROM exercice_solved S NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "hint" AS kind, time, id_exercice, H.id_hint, H.title FROM team_hints T INNER JOIN exercice_hints H ON H.id_hint = T.id_hint NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "wchoices" AS kind, time, id_exercice, F.id_flag, F.type FROM team_wchoices W INNER JOIN exercice_flags F ON F.id_flag = W.id_flag NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "flag_found" AS kind, time, id_exercice, K.id_flag, K.type FROM flag_found F INNER JOIN exercice_flags K ON K.id_flag = F.id_flag NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "mcq_found" AS kind, time, id_exercice, Q.id_mcq, Q.title FROM mcq_found F INNER JOIN exercice_mcq Q ON Q.id_mcq = F.id_mcq NATURAL JOIN teams U WHERE id_exercice = ?
|
||||
if rows, err := DBQuery(`SELECT id_team, U.name, U.color, "tries" AS kind, time, 0, id_exercice, NULL, NULL FROM exercice_tries NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "solved" AS kind, time, coefficient, id_exercice, NULL, NULL FROM exercice_solved S NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "hint" AS kind, time, coefficient, id_exercice, H.id_hint, H.title FROM team_hints T INNER JOIN exercice_hints H ON H.id_hint = T.id_hint NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "wchoices" AS kind, time, coefficient, id_exercice, F.id_flag, F.type FROM team_wchoices W INNER JOIN exercice_flags F ON F.id_flag = W.id_flag NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "flag_found" AS kind, time, 0, id_exercice, K.id_flag, K.type FROM flag_found F INNER JOIN exercice_flags K ON K.id_flag = F.id_flag NATURAL JOIN teams U WHERE id_exercice = ? UNION
|
||||
SELECT id_team, U.name, U.color, "mcq_found" AS kind, time, 0, id_exercice, Q.id_mcq, Q.title FROM mcq_found F INNER JOIN exercice_mcq Q ON Q.id_mcq = F.id_mcq NATURAL JOIN teams U WHERE id_exercice = ?
|
||||
ORDER BY time DESC`, e.Id, e.Id, e.Id, e.Id, e.Id, e.Id); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
|
@ -26,11 +26,12 @@ func (e Exercice) GetHistory() ([]map[string]interface{}, error) {
|
|||
var team_color uint32
|
||||
var kind string
|
||||
var time time.Time
|
||||
var coeff float32
|
||||
var exercice int64
|
||||
var secondary *int64
|
||||
var secondary_title *string
|
||||
|
||||
if err := rows.Scan(&id_team, &team_name, &team_color, &kind, &time, &exercice, &secondary, &secondary_title); err != nil {
|
||||
if err := rows.Scan(&id_team, &team_name, &team_color, &kind, &time, &coeff, &exercice, &secondary, &secondary_title); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -41,6 +42,7 @@ func (e Exercice) GetHistory() ([]map[string]interface{}, error) {
|
|||
h["team_color"] = fmt.Sprintf("#%x", team_color)
|
||||
h["kind"] = kind
|
||||
h["time"] = time
|
||||
h["coefficient"] = coeff
|
||||
h["primary"] = e.Id
|
||||
if secondary != nil {
|
||||
h["secondary"] = secondary
|
||||
|
|
Reference in a new issue