From e878d6e281b98192c4ec17f997ff4679bff70e71 Mon Sep 17 00:00:00 2001 From: Baptiste Marcel Date: Wed, 6 Dec 2023 13:48:55 +0100 Subject: [PATCH] Modif affichage stats scoreboard + modif DESC to ASC dans DBService --- .../server/api/services/DatabaseService.js | 12 ++++++------ cryptide_project/src/Components/ScoreBoard.tsx | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cryptide_project/server/api/services/DatabaseService.js b/cryptide_project/server/api/services/DatabaseService.js index 7074dee..8742bfc 100644 --- a/cryptide_project/server/api/services/DatabaseService.js +++ b/cryptide_project/server/api/services/DatabaseService.js @@ -138,7 +138,7 @@ class DatabaseService { // Récupérer les 5 meilleurs scores de la journée this.client.all( - 'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY score DESC LIMIT 10', + 'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY score ASC LIMIT 10', "mastermind", currentDate, (err, result) => { @@ -157,7 +157,7 @@ class DatabaseService { const currentDate = new Date().toISOString().slice(0, 10); this.client.all( - 'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY time DESC LIMIT 10', + 'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) = ? ORDER BY time ASC LIMIT 10', enigmaLevel, currentDate, (err, result) => { @@ -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 DESC 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 ASC LIMIT 10', "multijoueur", currentDate, 1, (err, result) => { if (err) { @@ -201,7 +201,7 @@ class DatabaseService { const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10); this.client.all( - 'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY score DESC LIMIT 10', + 'SELECT pseudo, score FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY score ASC LIMIT 10', "mastermind", firstDayOfWeek, currentDate, @@ -223,7 +223,7 @@ class DatabaseService { const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10); this.client.all( - 'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY time DESC LIMIT 10', + 'SELECT pseudo, time FROM users INNER JOIN games ON users.idUser = games.idUser WHERE gameType = ? AND SUBSTR(playedDate, 1, 10) BETWEEN ? AND ? ORDER BY time ASC LIMIT 10', enigmaLevel, firstDayOfWeek, currentDate, @@ -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 DESC 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 = ? ORDER BY wins ASC LIMIT 10', "multijoueur", firstDayOfWeek, currentDate, diff --git a/cryptide_project/src/Components/ScoreBoard.tsx b/cryptide_project/src/Components/ScoreBoard.tsx index e3ad3d4..7d3e617 100644 --- a/cryptide_project/src/Components/ScoreBoard.tsx +++ b/cryptide_project/src/Components/ScoreBoard.tsx @@ -187,7 +187,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { MasterMind : {dailyMastermindStats !== null ? (dailyMastermindStats.tab.length !== 0 ? dailyMastermindStats.tab.map((stats: any, index: number) => ( - {stats.pseudo} + {index+1}.{stats.pseudo} {stats.score} )) : ( @@ -205,7 +205,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { Multijoueur : {dailyOnlineStats !== null ? (dailyOnlineStats.tab.length !== 0 ? dailyOnlineStats.tab.map((stats: any, index: number) => ( - {stats.pseudo} + {index+1}.{stats.pseudo} {stats.wins} )) : ( @@ -223,7 +223,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { Enigme facile : {dailyEasyEnigmaStats !== null ? (dailyEasyEnigmaStats.tab.length !== 0 ? dailyEasyEnigmaStats.tab.map((stats: any, index: number) => ( - {stats.pseudo} + {index+1}.{stats.pseudo} {stats.time} )) : ( @@ -249,7 +249,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { MasterMind : {weeklyMastermindStats !== null ? (weeklyMastermindStats.tab.length !== 0 ? weeklyMastermindStats.tab.map((stats: any, index: number) => ( - {stats.pseudo} + {index+1}.{stats.pseudo} {stats.score} )) : ( @@ -265,7 +265,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { Multijoueur : {weeklyOnlineStats !== null ? (weeklyOnlineStats.tab.length !== 0 ? weeklyOnlineStats.tab.map((stats: any, index: number) => ( - {stats.pseudo} + {index+1}.{stats.pseudo} {stats.wins} )) : ( @@ -283,7 +283,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => { Enigme facile : {weeklyEasyEnigmaStats !== null ? (weeklyEasyEnigmaStats.tab.length !== 0 ? weeklyEasyEnigmaStats.tab.map((stats: any, index: number) => ( - {stats.pseudo} + {index+1}.{stats.pseudo} {stats.time} )) : (