rank: count wchoices in score

This commit is contained in:
nemunaire 2018-12-06 22:02:47 +01:00
parent 2c5144aac0
commit 8dc460b507

View File

@ -23,7 +23,8 @@ func exoptsQuery(whereExo string) string {
func rankQuery(whereTeam string) string {
return `SELECT A.id_team, SUM(A.points * A.coeff) AS score, MAX(A.time) AS time FROM (
` + exoptsQuery("") + ` UNION ALL
SELECT D.id_team, D.time, H.cost AS points, -1.0 AS coeff FROM team_hints D INNER JOIN exercice_hints H ON H.id_hint = D.id_hint HAVING points != 0
SELECT D.id_team, D.time, H.cost AS points, -1.0 AS coeff FROM team_hints D INNER JOIN exercice_hints H ON H.id_hint = D.id_hint HAVING points != 0 UNION ALL
SELECT W.id_team, W.time, F.choices_cost AS points, -1.0 AS coeff FROM team_wchoices W INNER JOIN exercice_flags F ON F.id_flag = W.id_flag HAVING points != 0
) A ` + whereTeam + ` GROUP BY A.id_team ORDER BY score DESC, time ASC`
}