Merge branch 'master' of https://codefirst.iut.uca.fr/git/Crypteam/Cryptid into tuto
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
441c980866
Binary file not shown.
@ -0,0 +1,209 @@
|
||||
const path = require('path');
|
||||
const DatabaseService = require(path.resolve(__dirname, '../services/DatabaseService'));
|
||||
|
||||
const ENIGME_FACILE = "enigme_facile";
|
||||
const ENIGME_MOYEN = "enigme_moyenne";
|
||||
const ENIGME_DIFFICILE = "enigme_difficile";
|
||||
|
||||
class SessionController {
|
||||
// ---------------------------------------------------
|
||||
// ----------------- GET DAILY STATS -----------------
|
||||
// ---------------------------------------------------
|
||||
|
||||
static async getDailyMastermind(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const dailyMastermindStats = await db.getDailyMastermindStats();
|
||||
|
||||
res.status(200).json({ tab : dailyMastermindStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyMastermind.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyEasyEnigma(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const dailyEasyEnigmaStats = await db.getDailyEnigmaStats(ENIGME_FACILE);
|
||||
|
||||
res.status(200).json({ tab : dailyEasyEnigmaStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyEasyEnigma.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyMediumEnigma(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const dailyMediumEnigmaStats = await db.getDailyEnigmaStats(ENIGME_MOYEN);
|
||||
|
||||
res.status(200).json({ tab : dailyMediumEnigmaStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyMediumEnigma.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyHardEnigma(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const dailyHardEnigmaStats = await db.getDailyEnigmaStats(ENIGME_DIFFICILE);
|
||||
|
||||
res.status(200).json({ tab : dailyHardEnigmaStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyHardEnigma.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyOnline(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const dailyOnlineStats = await db.getDailyOnlineStats();
|
||||
|
||||
res.status(200).json({ tab : dailyOnlineStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats dailyOnline' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
// ---------------- GET WEEKLY STATS -----------------
|
||||
// ---------------------------------------------------
|
||||
|
||||
static async getWeeklyMastermind(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const weeklyMastermindStats = await db.getWeeklyMastermindStats();
|
||||
|
||||
res.status(200).json({ tab : weeklyMastermindStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyMastermind.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyEasyEnigma(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const weeklyEasyEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_FACILE);
|
||||
|
||||
res.status(200).json({ tab : weeklyEasyEnigmaStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyEasyEnigma.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyMediumEnigma(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const weeklyMediumEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_MOYEN);
|
||||
|
||||
res.status(200).json({ tab : weeklyMediumEnigmaStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyMediumEnigma.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyHardEnigma(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const weeklyHardEnigmaStats = await db.getWeeklyEnigmaStats(ENIGME_DIFFICILE);
|
||||
|
||||
res.status(200).json({ tab : weeklyHardEnigmaStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyHardEnigma.' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyOnline(req, res){
|
||||
const db = new DatabaseService();
|
||||
|
||||
try{
|
||||
await db.connect();
|
||||
|
||||
const weeklyOnlineStats = await db.getWeeklyOnlineStats();
|
||||
|
||||
res.status(200).json({ tab : weeklyOnlineStats });
|
||||
}
|
||||
catch(error){
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Erreur lors de la récupération des stats weeklyOnline' });
|
||||
}
|
||||
finally{
|
||||
await db.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = SessionController;
|
@ -0,0 +1,15 @@
|
||||
/* Ajoutez ces styles dans votre fichier CSS ou utilisez un préprocesseur comme SCSS */
|
||||
.tabsStats {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.stats {
|
||||
background-color: #f0f0f0;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Personnalisez davantage selon vos préférences */
|
||||
|
@ -0,0 +1,244 @@
|
||||
import {ADRESSE_DBSERVER} from '../AdressSetup';
|
||||
|
||||
class ScoreboardService {
|
||||
|
||||
// ------------------------------ GET ------------------------------
|
||||
// ----------------------------- DAILY -----------------------------
|
||||
// ----------------------------- STATS -----------------------------
|
||||
|
||||
static async getDailyMastermindStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyMastermind', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyEasyEnigmaStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyEasyEnigma', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyMediumEnigmaStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyMediumEnigma', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyHardEnigmaStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyHardEnigma', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getDailyOnlineStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyOnline', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------ GET ------------------------------
|
||||
// ----------------------------- WEEKLY ----------------------------
|
||||
// ----------------------------- STATS -----------------------------
|
||||
|
||||
static async getWeeklyMastermindStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyMastermind', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyEasyEnigmaStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyEasyEnigma', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyMediumEnigmaStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyMediumEnigma', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyHardEnigmaStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyHardEnigma', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async getWeeklyOnlineStats() {
|
||||
try {
|
||||
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyOnline', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ScoreboardService;
|
Loading…
Reference in new issue