From a4f8c4686972b00a001f5bfce4e8c9e193a91e27 Mon Sep 17 00:00:00 2001 From: "Dario G. Mori" Date: Thu, 25 Apr 2024 14:38:26 +0200 Subject: [PATCH 1/6] feat: image pruning for releasing space --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 76fff00f..bf5d60ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -175,3 +175,4 @@ jobs: echo "SSL_PASSWORD=${{ secrets.SSL_PASSWORD }}" >> .env docker compose --profile prod down docker compose --profile prod up -d --pull always + docker image prune From 4179d022f4b0811c3e3ff86644e4392f3874963e Mon Sep 17 00:00:00 2001 From: "Dario G. Mori" Date: Thu, 25 Apr 2024 14:48:35 +0200 Subject: [PATCH 2/6] feat: removed music type of questions --- .../java/lab/en2b/quizapi/commons/utils/GameModeUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java b/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java index eaf16af9..31b503da 100644 --- a/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java +++ b/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java @@ -70,11 +70,12 @@ private static List getQuestionCategoriesEn(){ .description("Are you an art expert? Prove it!") .internalRepresentation(QuestionCategory.ART) .build(), + /** QuestionCategoryDto.builder() .name("Music") .description("Are you a music lover? Prove it!") .internalRepresentation(QuestionCategory.MUSIC) - .build(), + .build(),*/ QuestionCategoryDto.builder() .name("Geography") .description("Are you a geography expert? Prove it!") From 124bf70662fff0d7fe257cd521e057a20559a39c Mon Sep 17 00:00:00 2001 From: jjgancfer Date: Thu, 25 Apr 2024 17:40:50 +0200 Subject: [PATCH 3/6] fix: changing language now changes game language --- webapp/src/components/game/Game.js | 2 +- webapp/src/pages/Game.jsx | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/webapp/src/components/game/Game.js b/webapp/src/components/game/Game.js index 6c70c410..18383d4c 100644 --- a/webapp/src/components/game/Game.js +++ b/webapp/src/components/game/Game.js @@ -37,7 +37,7 @@ export async function getCurrentQuestion(gameId) { return await authManager.getAxiosInstance().get(process.env.REACT_APP_API_ENDPOINT + "/games/" + gameId + "/question"); } -export async function changeLanguage(gameId, language) { +export async function changeGameLanguage(gameId, language) { await authManager.getAxiosInstance().put(process.env.REACT_APP_API_ENDPOINT + "/games/" + gameId + "/language?language=" + language); } diff --git a/webapp/src/pages/Game.jsx b/webapp/src/pages/Game.jsx index 029d884e..cac11836 100644 --- a/webapp/src/pages/Game.jsx +++ b/webapp/src/pages/Game.jsx @@ -4,7 +4,14 @@ import { Center } from "@chakra-ui/layout"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; import Confetti from "react-confetti"; -import { startRound, getCurrentQuestion, answerQuestion, getCurrentGame, getGameDetails } from '../components/game/Game'; +import { + startRound, + getCurrentQuestion, + answerQuestion, + getCurrentGame, + getGameDetails, + changeGameLanguage +} from '../components/game/Game'; import LateralMenu from '../components/menu/LateralMenu'; import MenuButton from '../components/menu/MenuButton'; import { HttpStatusCode } from "axios"; @@ -30,8 +37,9 @@ export default function Game() { const { t, i18n } = useTranslation(); const [isMenuOpen, setIsMenuOpen] = useState(false); - const changeLanguage = (selectedLanguage) => { - i18n.changeLanguage(selectedLanguage); + const changeLanguage = async (selectedLanguage) => { + await i18n.changeLanguage(selectedLanguage); + await changeGameLanguage(gameId, selectedLanguage); }; const calculateProgress = () => { From ef9453e8c499565385b9115b9d4393d91fbc0f7e Mon Sep 17 00:00:00 2001 From: "Dario G. Mori" Date: Thu, 25 Apr 2024 14:57:35 +0200 Subject: [PATCH 4/6] feat: game is over when no question found --- .../lab/en2b/quizapi/game/GameService.java | 16 +++++++- .../question/QuestionRepository.java | 3 +- .../questions/question/QuestionService.java | 16 ++++---- .../en2b/quizapi/game/GameServiceTest.java | 39 ++++++++++++------- .../questions/QuestionServiceTest.java | 6 +-- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/api/src/main/java/lab/en2b/quizapi/game/GameService.java b/api/src/main/java/lab/en2b/quizapi/game/GameService.java index d78db2f4..cccd2b31 100644 --- a/api/src/main/java/lab/en2b/quizapi/game/GameService.java +++ b/api/src/main/java/lab/en2b/quizapi/game/GameService.java @@ -1,9 +1,11 @@ package lab.en2b.quizapi.game; +import lab.en2b.quizapi.commons.exceptions.InternalApiErrorException; import lab.en2b.quizapi.commons.user.UserService; import lab.en2b.quizapi.commons.utils.GameModeUtils; import lab.en2b.quizapi.game.dtos.*; import lab.en2b.quizapi.game.mappers.GameResponseDtoMapper; +import lab.en2b.quizapi.questions.question.Question; import lab.en2b.quizapi.questions.question.QuestionService; import lab.en2b.quizapi.questions.question.dtos.QuestionCategoryDto; import lab.en2b.quizapi.questions.question.dtos.QuestionResponseDto; @@ -55,18 +57,28 @@ public GameResponseDto newGame(String lang, GameMode gamemode, CustomGameDto new * @param authentication the authentication of the user * @return the game with the new round started */ - @Transactional public GameResponseDto startRound(Long id, Authentication authentication) { // Get the game by id and user Game game = gameRepository.findByIdForUser(id, userService.getUserByAuthentication(authentication).getId()).orElseThrow(); // Check if the game should be over wasGameMeantToBeOver(game); // Start a new round - game.newRound(questionService.findRandomQuestion(game.getLanguage(),game.getQuestionCategoriesForGamemode())); + game.newRound(generateQuestionForGame(game)); return gameResponseDtoMapper.apply(gameRepository.save(game)); } + private Question generateQuestionForGame(Game game){ + Optional question = questionService.findRandomQuestion(game.getLanguage(),game.getQuestionCategoriesForGamemode()); + if(question.isPresent()){ + return question.get(); + } else { + game.isGameOver(); + gameRepository.save(game); + throw new InternalApiErrorException("Could not find a question for the game"); + } + } + /** * Gets the current question for the game * @param id the id of the game to get the question for diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionRepository.java b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionRepository.java index 98688045..c8705461 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionRepository.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionRepository.java @@ -4,10 +4,11 @@ import org.springframework.data.jpa.repository.Query; import java.util.List; +import java.util.Optional; public interface QuestionRepository extends JpaRepository { @Query(value = "SELECT q.* FROM questions q INNER JOIN answers a ON q.correct_answer_id=a.id WHERE a.language = ?1 " + "AND q.question_category IN ?2 " + " ORDER BY RANDOM() LIMIT 1 ", nativeQuery = true) - Question findRandomQuestion(String lang, List questionCategories); + Optional findRandomQuestion(String lang, List questionCategories); } diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java index 667cfd8a..3d8d1115 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionService.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Optional; @Service @RequiredArgsConstructor @@ -42,7 +43,10 @@ else if(question.getAnswers().stream().noneMatch(i -> i.getId().equals(answerDto } public QuestionResponseDto getRandomQuestion(String lang) { - return questionResponseDtoMapper.apply(findRandomQuestion(lang, List.of(QuestionCategory.values()))); + Optional q = findRandomQuestion(lang, List.of(QuestionCategory.values())); + if(q.isEmpty()) + throw new InternalApiErrorException("No questions found"); + return questionResponseDtoMapper.apply(q.get()); } /** @@ -51,15 +55,13 @@ public QuestionResponseDto getRandomQuestion(String lang) { * @return The random question */ - public Question findRandomQuestion(String language, List questionCategoriesForCustom) { + public Optional findRandomQuestion(String language, List questionCategoriesForCustom) { if (language==null || language.isBlank()) { language = "en"; } - Question q = questionRepository.findRandomQuestion(language,questionCategoriesForCustom.stream().map(Enum::toString).toList()); - if(q==null) { - throw new InternalApiErrorException("No questions found for the specified language!"); - } - loadAnswers(q); + Optional q = questionRepository.findRandomQuestion(language,questionCategoriesForCustom.stream().map(Enum::toString).toList()); + q.ifPresent(this::loadAnswers); + return q; } diff --git a/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java b/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java index cc5b5e57..b91b9f37 100644 --- a/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java +++ b/api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java @@ -1,6 +1,7 @@ package lab.en2b.quizapi.game; import ch.qos.logback.core.util.TimeUtil; +import lab.en2b.quizapi.commons.exceptions.InternalApiErrorException; import lab.en2b.quizapi.commons.user.User; import lab.en2b.quizapi.commons.user.dtos.UserResponseDto; import lab.en2b.quizapi.commons.user.UserService; @@ -253,7 +254,7 @@ public void isGameActiveNoActiveGame(){ public void startRound(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); GameResponseDto gameDto = gameService.startRound(1L, authentication); GameResponseDto result = defaultGameResponseDto; @@ -262,11 +263,18 @@ public void startRound(){ result.setRoundStartTime(Instant.ofEpochMilli(defaultGame.getRoundStartTime()).toString()); assertEquals(result, gameDto); } - + @Test + public void startRoundNoQuestionCouldBeGenerated(){ + when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); + when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); + when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.empty()); + assertThrows(InternalApiErrorException.class, () -> gameService.startRound(1L, authentication)); + } @Test public void startRoundGameOver(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); defaultGame.setActualRound(10L); assertThrows(IllegalStateException.class, () -> gameService.startRound(1L,authentication)); @@ -276,7 +284,7 @@ public void startRoundGameOver(){ public void startRoundWhenRoundNotFinished(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); gameService.startRound(1L,authentication); assertThrows(IllegalStateException.class, () -> gameService.startRound(1L,authentication)); @@ -286,7 +294,7 @@ public void startRoundWhenRoundNotFinished(){ public void getCurrentQuestion() { when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); gameService.startRound(1L,authentication); QuestionResponseDto questionDto = gameService.getCurrentQuestion(1L,authentication); @@ -312,7 +320,7 @@ public void getCurrentQuestionRoundNotStarted() { public void getCurrentQuestionRoundFinished() { when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); gameService.startRound(1L,authentication); defaultGame.setRoundStartTime(Instant.now().minusSeconds(100).toEpochMilli()); @@ -324,7 +332,7 @@ public void getCurrentQuestionGameFinished() { when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.startRound(1L,authentication); defaultGame.setGameOver(true); defaultGame.setActualRound(10L); @@ -336,7 +344,7 @@ public void answerQuestionCorrectly(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); gameService.answerQuestion(1L, new GameAnswerDto(1L), authentication); @@ -350,7 +358,7 @@ public void answerQuestionIncorrectly(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); gameService.answerQuestion(1L, new GameAnswerDto(2L), authentication); @@ -364,7 +372,7 @@ public void answerQuestionWhenGameHasFinished(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); defaultGame.setGameOver(true); @@ -377,7 +385,7 @@ public void answerQuestionLastRound(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); defaultGame.setActualRound(8L); gameService.startRound(1L, authentication); @@ -390,7 +398,7 @@ public void answerQuestionWhenRoundHasFinished(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); defaultGame.setRoundStartTime(Instant.now().minusSeconds(100).toEpochMilli()); @@ -402,7 +410,7 @@ public void answerQuestionInvalidId(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); - when(questionService.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); assertThrows(IllegalArgumentException.class, () -> gameService.answerQuestion(1L, new GameAnswerDto(3L), authentication)); @@ -413,6 +421,7 @@ public void changeLanguage(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); gameService.changeLanguage(1L, "es", authentication); @@ -424,6 +433,7 @@ public void changeLanguage(){ public void changeLanguageGameOver(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); gameService.newGame(null,null,null,authentication); @@ -448,7 +458,7 @@ public void getGameDetails(){ when(gameRepository.findByIdForUser(any(), any())).thenReturn(Optional.of(defaultGame)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); - + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); GameResponseDto gameDto = gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); gameService.getGameDetails(1L, authentication); @@ -461,6 +471,7 @@ public void getGameDetailsInvalidId(){ when(gameRepository.findByIdForUser(1L, 1L)).thenReturn(Optional.of(defaultGame)); when(userService.getUserByAuthentication(authentication)).thenReturn(defaultUser); when(gameRepository.save(any())).thenAnswer(invocation -> invocation.getArgument(0)); + when(questionService.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); gameService.newGame(null,null,null,authentication); gameService.startRound(1L, authentication); assertThrows(NoSuchElementException.class, () -> gameService.getGameDetails(2L, authentication)); diff --git a/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java b/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java index 5d99584f..12e6a0fb 100644 --- a/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java +++ b/api/src/test/java/lab/en2b/quizapi/questions/QuestionServiceTest.java @@ -102,7 +102,7 @@ void setUp() { @Test void testGetRandomQuestion() { - when(questionRepository.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionRepository.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); QuestionResponseDto response = questionService.getRandomQuestion(""); assertEquals(response.getId(), defaultResponseDto.getId()); @@ -112,7 +112,7 @@ void testGetRandomQuestion() { void testGetRandomQuestionImageType() { defaultQuestion.setType(QuestionType.IMAGE); defaultQuestion.setContent("What is the capital of France?#* &%https://www.example.com/image.jpg"); - when(questionRepository.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionRepository.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); QuestionResponseDto response = questionService.getRandomQuestion("en"); defaultResponseDto.setType(QuestionType.IMAGE); defaultResponseDto.setImage("https://www.example.com/image.jpg"); @@ -121,7 +121,7 @@ void testGetRandomQuestionImageType() { @Test void testGetRandomQuestionAnswersNotYetLoaded() { - when(questionRepository.findRandomQuestion(any(),any())).thenReturn(defaultQuestion); + when(questionRepository.findRandomQuestion(any(),any())).thenReturn(Optional.of(defaultQuestion)); defaultQuestion.setAnswers(List.of()); QuestionResponseDto response = questionService.getRandomQuestion("en"); defaultResponseDto.setAnswers(List.of(AnswerResponseDto.builder() From b0c0fd8445e0d66bb43b52fdb9ab0c1b7ed36462 Mon Sep 17 00:00:00 2001 From: "Dario G. Mori" Date: Thu, 25 Apr 2024 17:42:36 +0200 Subject: [PATCH 5/6] feat: removed music question category --- .../java/lab/en2b/quizapi/commons/utils/GameModeUtils.java | 7 ++++--- .../en2b/quizapi/questions/question/QuestionCategory.java | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java b/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java index 31b503da..ebae7a1a 100644 --- a/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java +++ b/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java @@ -15,11 +15,11 @@ public static List getQuestionCategoriesForGamemode(GameMode g gamemode = KIWI_QUEST; } return switch (gamemode) { - case KIWI_QUEST -> List.of(QuestionCategory.ART, QuestionCategory.MUSIC, QuestionCategory.GEOGRAPHY); + case KIWI_QUEST -> List.of(QuestionCategory.ART,/* QuestionCategory.MUSIC, */ QuestionCategory.GEOGRAPHY); case FOOTBALL_SHOWDOWN -> List.of(QuestionCategory.SPORTS); case GEO_GENIUS -> List.of(QuestionCategory.GEOGRAPHY); case VIDEOGAME_ADVENTURE -> List.of(QuestionCategory.VIDEOGAMES); - case ANCIENT_ODYSSEY -> List.of(QuestionCategory.MUSIC,QuestionCategory.ART); + case ANCIENT_ODYSSEY -> List.of(/*QuestionCategory.MUSIC,*/QuestionCategory.ART); case RANDOM -> List.of(QuestionCategory.values()); case CUSTOM -> questionCategoriesForCustom; }; @@ -101,11 +101,12 @@ private static List getQuestionCategoriesEs(){ .description("¿Eres un experto en arte? ¡Demuéstralo!") .internalRepresentation(QuestionCategory.ART) .build(), + /** QuestionCategoryDto.builder() .name("Música") .description("¿Eres un melómano? ¡Demuéstralo!") .internalRepresentation(QuestionCategory.MUSIC) - .build(), + .build(),*/ QuestionCategoryDto.builder() .name("Geografía") .description("¿Eres un experto en geografía? ¡Demuéstralo!") diff --git a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionCategory.java b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionCategory.java index d97db494..a6f0e741 100644 --- a/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionCategory.java +++ b/api/src/main/java/lab/en2b/quizapi/questions/question/QuestionCategory.java @@ -2,5 +2,6 @@ public enum QuestionCategory { //HISTORY, GEOGRAPHY, SCIENCE, MATH, LITERATURE, ART, SPORTS, MUSIC, MOVIES, TV, POLITICS, OTHER - GEOGRAPHY, SPORTS, MUSIC, ART, VIDEOGAMES + GEOGRAPHY, SPORTS, //MUSIC, + ART, VIDEOGAMES } From 7dbcb919b497835a496954a973d45d20bf88abf9 Mon Sep 17 00:00:00 2001 From: "Dario G. Mori" Date: Thu, 25 Apr 2024 17:43:29 +0200 Subject: [PATCH 6/6] refactor: javadoc is comments now --- .../java/lab/en2b/quizapi/commons/utils/GameModeUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java b/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java index ebae7a1a..80c294bc 100644 --- a/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java +++ b/api/src/main/java/lab/en2b/quizapi/commons/utils/GameModeUtils.java @@ -70,7 +70,7 @@ private static List getQuestionCategoriesEn(){ .description("Are you an art expert? Prove it!") .internalRepresentation(QuestionCategory.ART) .build(), - /** + /* QuestionCategoryDto.builder() .name("Music") .description("Are you a music lover? Prove it!") @@ -101,7 +101,7 @@ private static List getQuestionCategoriesEs(){ .description("¿Eres un experto en arte? ¡Demuéstralo!") .internalRepresentation(QuestionCategory.ART) .build(), - /** + /* QuestionCategoryDto.builder() .name("Música") .description("¿Eres un melómano? ¡Demuéstralo!")