Compare commits

...

2 Commits

Author SHA1 Message Date
Baptiste MARCEL dc2bf3dafb Merge branch 'master' into weeklyDaily
continuous-integration/drone/push Build is passing Details
7 months ago
Baptiste MARCEL f863607efd correctif sur ordre affichage des victoires et également sur la requête pour les weeklyOnline
continuous-integration/drone/push Build is passing Details
7 months ago

@ -37,7 +37,7 @@ class SessionController {
nbGamesEF = nbGamesEF.nbGames || 0; nbGamesEF = nbGamesEF.nbGames || 0;
let nbWinsEF = await db.getNbWinsEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE); let nbWinsEF = await db.getNbWinsEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE);
nbWinsEF = nbWinsEF.nbWins || 0; 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); let bestTimeEF = await db.getBestTimeEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE);
bestTimeEF = bestTimeEF.bestTime || 0; bestTimeEF = bestTimeEF.bestTime || 0;
let avgTimeEF = await db.getAvgTimeEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE); let avgTimeEF = await db.getAvgTimeEnigmeByUserId(req.session.user.idUser, ENIGME_FACILE);
@ -66,7 +66,7 @@ class SessionController {
nbGamesED = nbGamesED.nbGames || 0; nbGamesED = nbGamesED.nbGames || 0;
let nbWinsED = await db.getNbWinsEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE); let nbWinsED = await db.getNbWinsEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE);
nbWinsED = nbWinsED.nbWins || 0; 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); let bestTimeED = await db.getBestTimeEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE);
bestTimeED = bestTimeED.bestTime || 0; bestTimeED = bestTimeED.bestTime || 0;
let avgTimeED = await db.getAvgTimeEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE); let avgTimeED = await db.getAvgTimeEnigmeByUserId(req.session.user.idUser, ENIGME_DIFFICILE);
@ -83,7 +83,7 @@ class SessionController {
nbGamesOL = nbGamesOL.nbGames || 0; nbGamesOL = nbGamesOL.nbGames || 0;
let nbWinsOL = await db.getNbWinsOnlineByUserId(req.session.user.idUser); let nbWinsOL = await db.getNbWinsOnlineByUserId(req.session.user.idUser);
nbWinsOL = nbWinsOL.nbWins || 0; nbWinsOL = nbWinsOL.nbWins || 0;
let ratioOL = (nbWinsOL.nbWins / nbGamesOL.nbGames) * 100 || 0; let ratioOL = (nbWinsOL / nbGamesOL) * 100 || 0;
req.session.user.onlineStats = {nbGames: nbGamesOL, req.session.user.onlineStats = {nbGames: nbGamesOL,
nbWins: nbWinsOL, nbWins: nbWinsOL,
ratio: ratioOL}; ratio: ratioOL};

@ -176,7 +176,7 @@ class DatabaseService {
const currentDate = new Date().toISOString().slice(0, 10); const currentDate = new Date().toISOString().slice(0, 10);
this.client.all( 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, "multijoueur", currentDate, 1,
(err, result) => { (err, result) => {
if (err) { if (err) {
@ -245,7 +245,7 @@ class DatabaseService {
const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10); const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - currentDay)).toISOString().slice(0, 10);
this.client.all( 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", "multijoueur",
firstDayOfWeek, firstDayOfWeek,
currentDate, currentDate,

@ -51,9 +51,9 @@ function AppNavbar({changeLocale, locale}) {
return ( return (
<Navbar expand="lg" className="custom-navbar" style={{ backgroundColor: theme.colors.primary }}> <Navbar expand="lg" className="custom-navbar" style={{ backgroundColor: theme.colors.primary }}>
<Container> <Container>
<Navbar.Brand onClick={navigateToHome}> <Nav.Link href={`${basePath}/`}>
<img src={logo} alt="logo" className="logo" /> <img src={logo} alt="logo" className="logo" />
</Navbar.Brand> </Nav.Link>
<Navbar.Toggle aria-controls="basic-navbar-nav" /> <Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav"> <Navbar.Collapse id="basic-navbar-nav">
<Nav className="me-auto"> <Nav className="me-auto">

@ -140,7 +140,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => {
<hr /> <hr />
<p>Parties Jouées: {Player.onlineStats.nbGames}</p> <p>Parties Jouées: {Player.onlineStats.nbGames}</p>
<p>Nombre de victoires: {Player.onlineStats.nbWins}</p> <p>Nombre de victoires: {Player.onlineStats.nbWins}</p>
<p>Ratio V/D: {Player.onlineStats.ratio.toFixed(2) + "s"}</p> <p>Ratio V/D: {Player.onlineStats.ratio.toFixed(2) + "%"}</p>
</div> </div>
</Carousel> </Carousel>
</Tab.Content> </Tab.Content>

@ -2,6 +2,7 @@ import {ADRESSE_DBSERVER} from "../AdressSetup"
class SessionService { class SessionService {
static async getSession() { static async getSession() {
try { try {
const response = await fetch(ADRESSE_DBSERVER + '/session', { const response = await fetch(ADRESSE_DBSERVER + '/session', {
method: 'GET', method: 'GET',
@ -10,9 +11,10 @@ class SessionService {
}, },
credentials: 'include', credentials: 'include',
}); });
if (response.ok) { if (response.ok) {
const result = await response.json(); const result = await response.json();
console.log(result);
return result; return result;
} else { } else {
const errorResponse = await response.json(); const errorResponse = await response.json();

Loading…
Cancel
Save