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;
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};

@ -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,

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

@ -140,7 +140,7 @@ const ScoreBoard: React.FC<{ Player: User }> = ({ Player }) => {
<hr />
<p>Parties Jouées: {Player.onlineStats.nbGames}</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>
</Carousel>
</Tab.Content>

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

Loading…
Cancel
Save