From e18ed652f0c9bef748b06841385868456ba89182 Mon Sep 17 00:00:00 2001 From: Thibaut Valentin Date: Mon, 17 Mar 2025 11:12:38 +0100 Subject: [PATCH] fix(cat): age map --- .../ffsaf/domain/service/MatchService.java | 13 +++++++------ src/main/java/fr/titionfire/ffsaf/utils/Utils.java | 14 +++++++------- src/main/webapp/src/utils/Tools.js | 14 +++++++------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/java/fr/titionfire/ffsaf/domain/service/MatchService.java b/src/main/java/fr/titionfire/ffsaf/domain/service/MatchService.java index 71c6896..d7e8b2a 100644 --- a/src/main/java/fr/titionfire/ffsaf/domain/service/MatchService.java +++ b/src/main/java/fr/titionfire/ffsaf/domain/service/MatchService.java @@ -5,6 +5,7 @@ import fr.titionfire.ffsaf.data.repository.CombRepository; import fr.titionfire.ffsaf.data.repository.MatchRepository; import fr.titionfire.ffsaf.data.repository.PouleRepository; import fr.titionfire.ffsaf.rest.data.MatchData; +import fr.titionfire.ffsaf.rest.exception.DNotFoundException; import fr.titionfire.ffsaf.utils.CompetitionSystem; import fr.titionfire.ffsaf.utils.ScoreEmbeddable; import fr.titionfire.ffsaf.utils.SecurityCtx; @@ -34,14 +35,14 @@ public class MatchService { public Uni getById(SecurityCtx securityCtx, CompetitionSystem system, Long id) { return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult() - .onItem().ifNull().failWith(() -> new RuntimeException("Match not found")) + .onItem().ifNull().failWith(() -> new DNotFoundException("Match not found")) .call(data -> permService.hasViewPerm(securityCtx, data.getPoule().getCompet())) .map(MatchData::fromModel); } public Uni> getAllByPoule(SecurityCtx securityCtx, CompetitionSystem system, Long id) { return pouleRepository.find("systemId = ?1 AND system = ?2", id, system).firstResult() - .onItem().ifNull().failWith(() -> new RuntimeException("Poule not found")) + .onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found")) .call(data -> permService.hasViewPerm(securityCtx, data.getCompet())) .chain(data -> repository.list("poule = ?1", data.getId()) .map(o -> o.stream().map(MatchData::fromModel).toList())); @@ -53,7 +54,7 @@ public class MatchService { if (o == null) { return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system) .firstResult() - .onItem().ifNull().failWith(() -> new RuntimeException("Poule not found")) + .onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found")) .call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet())) .map(pouleModel -> { MatchModel model = new MatchModel(); @@ -67,7 +68,7 @@ public class MatchService { } else { return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system) .firstResult() - .onItem().ifNull().failWith(() -> new RuntimeException("Poule not found")) + .onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found")) .call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet())) .map(__ -> o); } @@ -95,7 +96,7 @@ public class MatchService { public Uni updateScore(SecurityCtx securityCtx, CompetitionSystem system, Long id, List scores) { return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult() - .onItem().ifNull().failWith(() -> new RuntimeException("Match not found")) + .onItem().ifNull().failWith(() -> new DNotFoundException("Match not found")) .call(o2 -> permService.hasEditPerm(securityCtx, o2.getPoule().getCompet())) .invoke(data -> { data.getScores().clear(); @@ -107,7 +108,7 @@ public class MatchService { public Uni delete(SecurityCtx securityCtx, CompetitionSystem system, Long id) { return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult() - .onItem().ifNull().failWith(() -> new RuntimeException("Match not found")) + .onItem().ifNull().failWith(() -> new DNotFoundException("Match not found")) .call(o2 -> permService.hasEditPerm(securityCtx, o2.getPoule().getCompet())) .chain(data -> Panache.withTransaction(() -> repository.delete(data))); } diff --git a/src/main/java/fr/titionfire/ffsaf/utils/Utils.java b/src/main/java/fr/titionfire/ffsaf/utils/Utils.java index b3e4fb2..b4a74a9 100644 --- a/src/main/java/fr/titionfire/ffsaf/utils/Utils.java +++ b/src/main/java/fr/titionfire/ffsaf/utils/Utils.java @@ -48,19 +48,19 @@ public class Utils { int birthYear = toCalendar(birth_date).get(Calendar.YEAR); int diff = currentSaison - birthYear; - if (diff < 7) { + if (diff < 6) { return Categorie.SUPER_MINI; - } else if (diff < 9) { + } else if (diff < 8) { return Categorie.MINI_POUSSIN; - } else if (diff < 11) { + } else if (diff < 10) { return Categorie.POUSSIN; - } else if (diff < 13) { + } else if (diff < 12) { return Categorie.BENJAMIN; - } else if (diff < 15) { + } else if (diff < 14) { return Categorie.MINIME; - } else if (diff < 17) { + } else if (diff < 16) { return Categorie.CADET; - } else if (diff < 19) { + } else if (diff < 18) { return Categorie.JUNIOR; } else if (diff < 25) { return Categorie.SENIOR1; diff --git a/src/main/webapp/src/utils/Tools.js b/src/main/webapp/src/utils/Tools.js index 8d87458..a9f105e 100644 --- a/src/main/webapp/src/utils/Tools.js +++ b/src/main/webapp/src/utils/Tools.js @@ -17,19 +17,19 @@ export function getCategoryFormBirthDate(birth_date, currentDate = new Date()) { const birthYear = birth_date.getFullYear() const diff = currentSaison - birthYear; - if (diff < 7) { + if (diff < 6) { return "SUPER_MINI"; - } else if (diff < 9) { + } else if (diff < 8) { return "MINI_POUSSIN"; - } else if (diff < 11) { + } else if (diff < 10) { return "POUSSIN"; - } else if (diff < 13) { + } else if (diff < 12) { return "BENJAMIN"; - } else if (diff < 15) { + } else if (diff < 14) { return "MINIME"; - } else if (diff < 17) { + } else if (diff < 16) { return "CADET"; - } else if (diff < 19) { + } else if (diff < 18) { return "JUNIOR"; } else if (diff < 25) { return "SENIOR1";