diff --git a/cryptide_project/DB/socialgraph.db b/cryptide_project/DB/socialgraph.db index 7c46717..115a655 100644 Binary files a/cryptide_project/DB/socialgraph.db and b/cryptide_project/DB/socialgraph.db differ diff --git a/cryptide_project/server/api/controllers/SessionController.js b/cryptide_project/server/api/controllers/SessionController.js index 1fc1fc4..724e6cb 100644 --- a/cryptide_project/server/api/controllers/SessionController.js +++ b/cryptide_project/server/api/controllers/SessionController.js @@ -37,7 +37,7 @@ class SessionController { nbGamesEF = nbGamesEF.nbGames || 0; let nbWinsEF = await db.getNbWinsEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE); nbWinsEF = nbWinsEF.nbWins || 0; - let ratioEF = (nbWinsEF.nbWins / nbGamesEF.nbGames) * 100 || 0; + let ratioEF = (nbWinsEF / nbGamesEF) * 100 || 0; let bestTimeEF = await db.getBestTimeEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE); bestTimeEF = bestTimeEF.bestTime || 0; let avgTimeEF = await db.getAvgTimeEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE); @@ -66,7 +66,7 @@ class SessionController { nbGamesED = nbGamesED.nbGames || 0; let nbWinsED = await db.getNbWinsEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE); nbWinsED = nbWinsED.nbWins || 0; - let ratioED = (nbWinsED.nbWins / nbGamesED.nbGames) * 100 || 0; + let ratioED = (nbWinsED / nbGamesED) * 100 || 0; let bestTimeED = await db.getBestTimeEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE); bestTimeED = bestTimeED.bestTime || 0; let avgTimeED = await db.getAvgTimeEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE); @@ -83,7 +83,7 @@ class SessionController { nbGamesOL = nbGamesOL.nbGames || 0; let nbWinsOL = await db.getNbWinsOnlineByUserId(req.session.user.idUser); nbWinsOL = nbWinsOL.nbWins || 0; - let ratioOL = (nbWinsOL.nbWins / nbGamesOL.nbGames) * 100 || 0; + let ratioOL = (nbWinsOL / nbGamesOL) * 100 || 0; req.session.user.onlineStats = {nbGames: nbGamesOL, nbWins: nbWinsOL, ratio: ratioOL}; diff --git a/cryptide_project/server/api/services/DatabaseService.js b/cryptide_project/server/api/services/DatabaseService.js index 8742bfc..a0c60dc 100644 --- a/cryptide_project/server/api/services/DatabaseService.js +++ b/cryptide_project/server/api/services/DatabaseService.js @@ -176,7 +176,7 @@ class DatabaseService { const currentDate = new Date().toISOString().slice(0, 10); this.client.all( - 'SELECT pseudo, COUNT(*) AS wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? AND win = ? GROUP BY users.idUser ORDER BY wins ASC LIMIT 10', + 'SELECT pseudo, COUNT(*) AS wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? AND win = ? GROUP BY users.idUser ORDER BY wins DESC LIMIT 10', "multijoueur", currentDate, 1, (err, result) => { if (err) { @@ -245,7 +245,7 @@ class DatabaseService { const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10); this.client.all( - 'SELECT pseudo, COUNT(*) as wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? AND win = ? ORDER BY wins ASC LIMIT 10', + 'SELECT pseudo, COUNT(*) as wins FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? AND win = ? GROUP BY users.idUser ORDER BY wins DESC LIMIT 10', "multijoueur", firstDayOfWeek, currentDate, diff --git a/cryptide_project/src/Components/NavBar.tsx b/cryptide_project/src/Components/NavBar.tsx index 548f34a..5151a22 100644 --- a/cryptide_project/src/Components/NavBar.tsx +++ b/cryptide_project/src/Components/NavBar.tsx @@ -51,9 +51,9 @@ function AppNavbar({changeLocale}) { return ( - + logo - +