changement pour mysql
continuous-integration/drone/push Build is failing Details

CI/CD
Thomas Chazot 7 months ago
parent 51fd2d51ef
commit 41217810fe

@ -65,7 +65,7 @@ class DatabaseService {
// Récupère l'utilisateur par son id
async getUserByID(id){
return new Promise((resolve, reject) => {
this.client.query('SELECT * FROM users WHERE idUser = ?', id, (err, result) => {
this.client.query('SELECT * FROM users WHERE idUser = ?', [id], (err, result) => {
if(err){
reject(err);
}
@ -79,7 +79,7 @@ class DatabaseService {
// Récupère l'utilisateur par son pseudo
async getUserByPseudo(pseudo){
return new Promise((resolve, reject) => {
this.client.query('SELECT * FROM users WHERE pseudo = ?', pseudo, (err, result) => {
this.client.query('SELECT * FROM users WHERE pseudo = ?', [pseudo], (err, result) => {
if(err){
reject(err);
}
@ -106,7 +106,7 @@ class DatabaseService {
async deleteUser(userId){
return new Promise((resolve, reject) => {
this.client.query('DELETE FROM users WHERE idUser=?', userId, (err, result) => {
this.client.query('DELETE FROM users WHERE idUser=?', [userId], (err, result) => {
if(err){
reject(err);
}
@ -119,7 +119,7 @@ class DatabaseService {
async updatePseudo(userId, newPseudo){
return new Promise((resolve, reject) => {
this.client.query('UPDATE users SET pseudo = ? WHERE idUser = ?', newPseudo, userId, (err, result) => {
this.client.query('UPDATE users SET pseudo = ? WHERE idUser = ?', [newPseudo, userId], (err, result) => {
if(err){
reject(err);
}
@ -132,7 +132,7 @@ class DatabaseService {
async updatePassword(userId, newPassword){
return new Promise((resolve, reject) => {
this.client.query('UPDATE users SET password = ? WHERE idUser = ?', newPassword, userId, (err, result) => {
this.client.query('UPDATE users SET password = ? WHERE idUser = ?', [newPassword, userId], (err, result) => {
if(err){
reject(err);
}
@ -156,7 +156,7 @@ class DatabaseService {
this.client.query(
'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,
[currentDate],
(err, result) => {
if (err) {
reject(err);
@ -174,8 +174,8 @@ class DatabaseService {
this.client.query(
'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,
[enigmaLevel,
currentDate],
(err, result) => {
if (err) {
reject(err);
@ -193,7 +193,7 @@ class DatabaseService {
this.client.query(
'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,
["multijoueur", currentDate, 1],
(err, result) => {
if (err) {
reject(err);
@ -218,9 +218,9 @@ class DatabaseService {
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 ASC LIMIT 10',
"mastermind",
["mastermind",
firstDayOfWeek,
currentDate,
currentDate],
(err, result) => {
if (err) {
reject(err);
@ -240,9 +240,9 @@ class DatabaseService {
this.client.query(
'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,
[enigmaLevel,
firstDayOfWeek,
currentDate,
currentDate],
(err, result) => {
if (err) {
reject(err);
@ -262,9 +262,9 @@ class DatabaseService {
this.client.query(
'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",
["multijoueur",
firstDayOfWeek,
currentDate,
currentDate],
1,
(err, result) => {
if (err) {
@ -283,7 +283,7 @@ class DatabaseService {
async getNbGamesMastermindByUserId(userId){
return new Promise((resolve, reject) => {
this.client.query('SELECT COUNT(*) AS nbGames FROM games WHERE idUser = ? AND gameType = ?', userId, "mastermind", (err, result) => {
this.client.query('SELECT COUNT(*) AS nbGames FROM games WHERE idUser = ? AND gameType = ?', [userId, "mastermind"], (err, result) => {
if(err){
reject(err);
}
@ -296,7 +296,7 @@ class DatabaseService {
async getBestScoreMastermindByUserId(userId){
return new Promise((resolve, reject) => {
this.client.query('SELECT MIN(score) AS bestScore FROM games WHERE idUser = ? AND gameType = ?', userId, "mastermind", (err, result) => {
this.client.query('SELECT MIN(score) AS bestScore FROM games WHERE idUser = ? AND gameType = ?', [userId, "mastermind"], (err, result) => {
if(err){
reject(err);
}
@ -309,7 +309,7 @@ class DatabaseService {
async getAvgNbTryMastermindByUserId(userId){
return new Promise((resolve, reject) => {
this.client.query('SELECT AVG(score) AS avgNbTry FROM games WHERE idUser = ? AND gameType = ?', userId, "mastermind", (err, result) => {
this.client.query('SELECT AVG(score) AS avgNbTry FROM games WHERE idUser = ? AND gameType = ?', [userId, "mastermind"], (err, result) => {
if(err){
reject(err);
}
@ -322,7 +322,7 @@ class DatabaseService {
async addMastermindStats(userId, score, time){
return new Promise((resolve, reject) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', userId, "mastermind", 1, score, time, (err, result) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', [userId, "mastermind", 1, score, time], (err, result) => {
if(err){
reject(err);
}
@ -338,7 +338,7 @@ class DatabaseService {
async getNbGamesOnlineByUserId(userId){
return new Promise((resolve, reject) => {
this.client.query('SELECT COUNT(*) AS nbGames FROM games WHERE idUser = ? AND gameType = ?', userId, "multijoueur", (err, result) => {
this.client.query('SELECT COUNT(*) AS nbGames FROM games WHERE idUser = ? AND gameType = ?', [userId, "multijoueur"], (err, result) => {
if(err){
reject(err);
}
@ -351,7 +351,7 @@ class DatabaseService {
async getNbWinsOnlineByUserId(userId){
return new Promise((resolve, reject) => {
this.client.query('SELECT COUNT(*) AS nbWins FROM games WHERE idUser = ? AND gameType = ? AND win = ?', userId, "multijoueur", 1, (err, result) => {
this.client.query('SELECT COUNT(*) AS nbWins FROM games WHERE idUser = ? AND gameType = ? AND win = ?', [userId, "multijoueur", 1], (err, result) => {
if(err){
reject(err);
}
@ -364,7 +364,7 @@ class DatabaseService {
async addOnlineStats(userId, win, time){
return new Promise((resolve, reject) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', userId, "multijoueur", win, 0, time, (err, result) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', [userId, "multijoueur", win, 0, time], (err, result) => {
if(err){
reject(err);
}
@ -381,7 +381,7 @@ class DatabaseService {
async getNbGamesEnigmeByUserId(userId, enigmaLevel){
return new Promise((resolve, reject) => {
this.client.query('SELECT COUNT(*) AS nbGames FROM games WHERE idUser = ? AND gameType = ?', userId, enigmaLevel, (err, result) => {
this.client.query('SELECT COUNT(*) AS nbGames FROM games WHERE idUser = ? AND gameType = ?', [userId, enigmaLevel], (err, result) => {
if(err){
reject(err);
}
@ -394,7 +394,7 @@ class DatabaseService {
async getNbWinsEnigmeByUserId(userId, enigmaLevel){
return new Promise((resolve, reject) => {
this.client.query('SELECT COUNT(*) AS nbWins FROM games WHERE idUser = ? AND gameType = ? AND win = ?', userId, enigmaLevel, 1, (err, result) => {
this.client.query('SELECT COUNT(*) AS nbWins FROM games WHERE idUser = ? AND gameType = ? AND win = ?', [userId, enigmaLevel, 1], (err, result) => {
if(err){
reject(err);
}
@ -407,7 +407,7 @@ class DatabaseService {
async getBestScoreEnigmeByUserId(userId, enigmaLevel){
return new Promise((resolve, reject) => {
this.client.query('SELECT MAX(score) AS bestScore FROM games WHERE idUser = ? AND gameType = ?', userId, enigmaLevel, (err, result) => {
this.client.query('SELECT MAX(score) AS bestScore FROM games WHERE idUser = ? AND gameType = ?', [userId, enigmaLevel], (err, result) => {
if(err){
reject(err);
}
@ -420,7 +420,7 @@ class DatabaseService {
async getAvgScoreEnigmeByUserId(userId, enigmaLevel){
return new Promise((resolve, reject) => {
this.client.query('SELECT AVG(score) AS avgScore FROM games WHERE idUser = ? AND gameType = ?', userId, enigmaLevel, (err, result) => {
this.client.query('SELECT AVG(score) AS avgScore FROM games WHERE idUser = ? AND gameType = ?', [userId, enigmaLevel], (err, result) => {
if(err){
reject(err);
}
@ -433,7 +433,7 @@ class DatabaseService {
async getBestTimeEnigmeByUserId(userId, enigmaLevel){
return new Promise((resolve, reject) => {
this.client.query('SELECT MIN(time) AS bestTime FROM games WHERE idUser = ? AND gameType = ?', userId, enigmaLevel, (err, result) => {
this.client.query('SELECT MIN(time) AS bestTime FROM games WHERE idUser = ? AND gameType = ?', [userId, enigmaLevel], (err, result) => {
if(err){
reject(err);
}
@ -446,7 +446,7 @@ class DatabaseService {
async getAvgTimeEnigmeByUserId(userId, enigmaLevel){
return new Promise((resolve, reject) => {
this.client.query('SELECT AVG(time) AS avgTime FROM games WHERE idUser = ? AND gameType = ?', userId, enigmaLevel, (err, result) => {
this.client.query('SELECT AVG(time) AS avgTime FROM games WHERE idUser = ? AND gameType = ?', [userId, enigmaLevel], (err, result) => {
if(err){
reject(err);
}
@ -459,7 +459,7 @@ class DatabaseService {
async addEasyEnigmaStats(userId, enigmaLevel, win, time){
return new Promise((resolve, reject) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', userId, enigmaLevel, win, 0, time, (err, result) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', [userId, enigmaLevel, win, 0, time], (err, result) => {
if(err){
reject(err);
}
@ -474,7 +474,7 @@ class DatabaseService {
async addHardEnigmaStats(userId, enigmaLevel, win, time){
return new Promise((resolve, reject) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', userId, enigmaLevel, win, 0, time, (err, result) => {
this.client.query('INSERT INTO games (idUser, gameType, win, score, time) VALUES (?, ?, ?, ?, ?)', [userId, enigmaLevel, win, 0, time], (err, result) => {
if(err){
reject(err);
}

Loading…
Cancel
Save