From 2f591afa61aee57577627c9c79f07781dac22c05 Mon Sep 17 00:00:00 2001 From: Michael Truell Date: Fri, 23 Dec 2016 21:40:38 +0000 Subject: [PATCH] Closes #347 --- website/api/manager/ManagerAPI.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/website/api/manager/ManagerAPI.php b/website/api/manager/ManagerAPI.php index 06ede14a3..a4ab2e500 100644 --- a/website/api/manager/ManagerAPI.php +++ b/website/api/manager/ManagerAPI.php @@ -188,7 +188,6 @@ protected function game() { $s3Client->putObject($args); } - // Check that we arent stoing too many games in db $numAllowed = 100000; $res = mysqli_query($this->mysqli, "SELECT * FROM Game"); @@ -256,10 +255,13 @@ protected function game() { usort($allUsers, function($a, $b) { return $a['mu']-3*$a['sigma'] < $b['mu']-3*$b['sigma']; }); + $query = "UPDATE User set rank = CASE"; for($userIndex = 0; $userIndex < count($allUsers); $userIndex++) { $rank = $userIndex+1; - $this->insert("UPDATE User SET rank={$rank} WHERE userID={$allUsers[$userIndex]['userID']}"); + $query .= " WHEN userID = {$allUsers[$userIndex]['userID']} THEN {$rank}"; } + $query .= " ELSE rank END;"; + $this->insert($query); } }