fix(cat): age map
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 6m55s

This commit is contained in:
Thibaut Valentin 2025-03-17 11:12:38 +01:00
parent 7497cc399c
commit e18ed652f0
3 changed files with 21 additions and 20 deletions

View File

@ -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<MatchData> 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<List<MatchData>> 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<ScoreEmbeddable> 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)));
}

View File

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

View File

@ -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";