From 5b6b259b81ebbd2cb6b7d2d82b650f775107ce31 Mon Sep 17 00:00:00 2001 From: "johan.lachenal" Date: Wed, 23 Nov 2022 22:27:42 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20gateway=20permettant=20de=20r?= =?UTF-8?q?=C3=A9colter=20les=20donn=C3=A9es=20pour=20le=20dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/PartieGateway.php | 33 +++++++++++++++++++++++++++ WEB/Controller/UtilisateurGateway.php | 4 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 6160c77a..ee4a137e 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -55,6 +55,39 @@ class PartieGateway } return $listePartie; } + + public function getDashBoardData(Partie $partie) : array{ + $query="SELECT joueur + FROM Participer p + WHERE p.partie=:idPartie"; + $this->con->executeQuery($query,array( + 'idPartie' => array($partie->getIdPartie(),PDO::PARAM_INT))); + $listeIdJoueur=$this->con->getResults(); + $DashboardData=array(); + foreach($listeIdJoueur as $joueur){ + $points=0; + $query="SELECT pe.utilisateur,pe.points,pe.temps,u.pseudo + FROM Utilisateur u,PasserEnigme pe,Partie p + WHERE points IS NOT NULL + AND u.email=pe.utilisateur + AND pe.partie=:idPartie + AND pe.utilisateur=:joueur + GROUP BY pe.utilisateur,pe.points,pe.temps,u.pseudo + ORDER BY u.pseudo,pe.temps ASC"; + $this->con->executequery($query,array( + 'idPartie' => array($partie->getIdPartie(),PDO::PARAM_INT), + 'joueur' => array($joueur,PDO::PARAM_STR))); + $results=$this->con->getResults(); + $joueurDashboardData=array(); + foreach($results as $row) + { + $points+=$row['pe.points']; + $joueurDashboardData[]=array($points,$row['pe.temps']); + } + $DashboardData[]=array($results[0]['u.pseudo'] => $joueurDashboardData); + } + return $DashboardData; + } public function showAll() : void{ $query= "SELECT * FROM Partie"; diff --git a/WEB/Controller/UtilisateurGateway.php b/WEB/Controller/UtilisateurGateway.php index 18ef5de8..908d92fb 100644 --- a/WEB/Controller/UtilisateurGateway.php +++ b/WEB/Controller/UtilisateurGateway.php @@ -1,5 +1,5 @@