From 74550f89071d2e77fcb3bc455a895ecb34c71f10 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 6 Dec 2018 21:28:06 +0100 Subject: [PATCH] rank: fix long running scoring error --- frontend/static/views/rules.html | 16 ++++++++-------- libfic/stats.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/static/views/rules.html b/frontend/static/views/rules.html index 627e16a5..2f6aa18e 100644 --- a/frontend/static/views/rules.html +++ b/frontend/static/views/rules.html @@ -28,7 +28,7 @@

Coût des tentatives

- Vous disposez de 9 tentatives pour trouver la/les solutions d'un + Vous disposez de 10 tentatives pour trouver la/les solutions d'un challenge. Au delà, chaque tentative vous fait perdre une petite quantité de points comme suit :

@@ -41,23 +41,23 @@ - 0 à 9 + 0 à 10 0 point - 10 à 19 + 11 à 20 - 20 à 29 + 21 à 30 - 30 à 39 + 31 à 40 - 40 à 49 + 41 à 50 @@ -74,10 +74,10 @@ Par exemple :

La dernière tentative (lorsque tous les flags sont bons) est comptabilisée diff --git a/libfic/stats.go b/libfic/stats.go index 30c9ec43..194834c9 100644 --- a/libfic/stats.go +++ b/libfic/stats.go @@ -13,7 +13,7 @@ var FirstBlood = 0.12 var SubmissionCostBase = 0.5 func exoptsQuery(whereExo string) string { - return "SELECT S.id_team, S.time, E.gain AS points, coeff FROM (SELECT id_team, id_exercice, MIN(time) AS time, " + fmt.Sprintf("%f", FirstBlood) + " AS coeff FROM exercice_solved GROUP BY id_exercice UNION SELECT id_team, id_exercice, time, coefficient AS coeff FROM exercice_solved) S INNER JOIN exercices E ON S.id_exercice = E.id_exercice " + whereExo + " UNION ALL SELECT id_team, MAX(time) AS time, (FLOOR(COUNT(*)/10 - 1) * (FLOOR(COUNT(*)/10)))/0.2 + (FLOOR(COUNT(*)/10) * (COUNT(*)%10)) AS points, " + fmt.Sprintf("%f", SubmissionCostBase * -1) + " AS coeff FROM exercice_tries S " + whereExo + " GROUP BY id_exercice" + return "SELECT S.id_team, S.time, E.gain AS points, coeff FROM (SELECT id_team, id_exercice, MIN(time) AS time, " + fmt.Sprintf("%f", FirstBlood) + " AS coeff FROM exercice_solved GROUP BY id_exercice UNION SELECT id_team, id_exercice, time, coefficient AS coeff FROM exercice_solved) S INNER JOIN exercices E ON S.id_exercice = E.id_exercice " + whereExo + " UNION ALL SELECT id_team, MAX(time) AS time, (FLOOR(COUNT(*)/10 - 1) * (FLOOR(COUNT(*)/10)))/0.2 + (FLOOR(COUNT(*)/10) * (COUNT(*)%10)) AS points, " + fmt.Sprintf("%f", SubmissionCostBase * -1) + " AS coeff FROM exercice_tries S " + whereExo + " GROUP BY id_exercice, id_team" } func rankQuery(whereTeam string) string {