diff --git a/docker-compose.yml b/docker-compose.yml index cb3c44be..522c2091 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,20 +20,6 @@ services: - "8003:8003" networks: - mynetwork - - statsservice: - container_name: statsservice-${teamname:-defaultASW} - image: ghcr.io/arquisoft/wiq_es1a/statsservice:latest - profiles: ["dev", "prod"] - build: ./statsservice - depends_on: - - mongodb - ports: - - "8004:8004" - networks: - - mynetwork - environment: - MONGODB_URI: mongodb://mongodb:27017/userdb statsservice: container_name: statsservice-${teamname:-defaultASW} @@ -90,7 +76,6 @@ services: - userservice - authservice - questionservice - - statsservice ports: - "8000:8000" networks: diff --git a/users/userservice/stats-getter.js b/users/userservice/stats-getter.js index 73a3b85b..1a258504 100644 --- a/users/userservice/stats-getter.js +++ b/users/userservice/stats-getter.js @@ -17,12 +17,13 @@ class StatsForUser { var totalPoints = 0; var totalCorrectQuestions = 0; var totalIncorrectQuestions = 0; - var avgTime=0; + var totalTime=0; for (const partida of partidas){ totalPoints += partida.points; totalCorrectQuestions += partida.correctAnswers; totalIncorrectQuestions += partida.incorrectAnswers; + totalTime+=partida.avgTime; } var avgPoints = nGamesPlayed > 0 ? @@ -31,6 +32,8 @@ class StatsForUser { var ratioCorrectToIncorrect = totalIncorrectQuestions !== 0 ? totalCorrectQuestions / totalIncorrectQuestions : totalCorrectQuestions; + var avgTime = nGamesPlayed > 0 ? totalTime / nGamesPlayed : 0; + var statsJSON = { username: username, nGamesPlayed: nGamesPlayed, @@ -38,7 +41,8 @@ class StatsForUser { totalPoints: totalPoints, totalCorrectQuestions: totalCorrectQuestions, totalIncorrectQuestions: totalIncorrectQuestions, - ratioCorrectToIncorrect: ratioCorrectToIncorrect + ratioCorrectToIncorrect: ratioCorrectToIncorrect, + avgTime: avgTime }; return statsJSON; diff --git a/webapp/src/pages/Stats/Stats.js b/webapp/src/pages/Stats/Stats.js index 2959c535..7ee9da5b 100644 --- a/webapp/src/pages/Stats/Stats.js +++ b/webapp/src/pages/Stats/Stats.js @@ -104,6 +104,7 @@ const Stats = () => {
   Preguntas Correctas Totales: {stats.totalCorrectQuestions}
   Preguntas Incorrectas Totales: {stats.totalIncorrectQuestions}
   Ratio Correctas/Incorrectas: {stats.ratioCorrectToIncorrect}
+
   Tiempo por pregunta (s): {stats.avgTime}

)}