Merge pull request 'fix(cat): age map' (#40) from dev into master
Reviewed-on: #40
This commit is contained in:
commit
de62510f45
@ -5,6 +5,7 @@ import fr.titionfire.ffsaf.data.repository.CombRepository;
|
|||||||
import fr.titionfire.ffsaf.data.repository.MatchRepository;
|
import fr.titionfire.ffsaf.data.repository.MatchRepository;
|
||||||
import fr.titionfire.ffsaf.data.repository.PouleRepository;
|
import fr.titionfire.ffsaf.data.repository.PouleRepository;
|
||||||
import fr.titionfire.ffsaf.rest.data.MatchData;
|
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.CompetitionSystem;
|
||||||
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
||||||
import fr.titionfire.ffsaf.utils.SecurityCtx;
|
import fr.titionfire.ffsaf.utils.SecurityCtx;
|
||||||
@ -34,14 +35,14 @@ public class MatchService {
|
|||||||
|
|
||||||
public Uni<MatchData> getById(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
public Uni<MatchData> getById(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
||||||
return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
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()))
|
.call(data -> permService.hasViewPerm(securityCtx, data.getPoule().getCompet()))
|
||||||
.map(MatchData::fromModel);
|
.map(MatchData::fromModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<List<MatchData>> getAllByPoule(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
public Uni<List<MatchData>> getAllByPoule(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
||||||
return pouleRepository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
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()))
|
.call(data -> permService.hasViewPerm(securityCtx, data.getCompet()))
|
||||||
.chain(data -> repository.list("poule = ?1", data.getId())
|
.chain(data -> repository.list("poule = ?1", data.getId())
|
||||||
.map(o -> o.stream().map(MatchData::fromModel).toList()));
|
.map(o -> o.stream().map(MatchData::fromModel).toList()));
|
||||||
@ -53,7 +54,7 @@ public class MatchService {
|
|||||||
if (o == null) {
|
if (o == null) {
|
||||||
return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system)
|
return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system)
|
||||||
.firstResult()
|
.firstResult()
|
||||||
.onItem().ifNull().failWith(() -> new RuntimeException("Poule not found"))
|
.onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found"))
|
||||||
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet()))
|
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet()))
|
||||||
.map(pouleModel -> {
|
.map(pouleModel -> {
|
||||||
MatchModel model = new MatchModel();
|
MatchModel model = new MatchModel();
|
||||||
@ -67,7 +68,7 @@ public class MatchService {
|
|||||||
} else {
|
} else {
|
||||||
return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system)
|
return pouleRepository.find("systemId = ?1 AND system = ?2", data.getPoule(), system)
|
||||||
.firstResult()
|
.firstResult()
|
||||||
.onItem().ifNull().failWith(() -> new RuntimeException("Poule not found"))
|
.onItem().ifNull().failWith(() -> new DNotFoundException("Poule not found"))
|
||||||
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet()))
|
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getCompet()))
|
||||||
.map(__ -> o);
|
.map(__ -> o);
|
||||||
}
|
}
|
||||||
@ -95,7 +96,7 @@ public class MatchService {
|
|||||||
public Uni<?> updateScore(SecurityCtx securityCtx, CompetitionSystem system, Long id,
|
public Uni<?> updateScore(SecurityCtx securityCtx, CompetitionSystem system, Long id,
|
||||||
List<ScoreEmbeddable> scores) {
|
List<ScoreEmbeddable> scores) {
|
||||||
return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
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()))
|
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getPoule().getCompet()))
|
||||||
.invoke(data -> {
|
.invoke(data -> {
|
||||||
data.getScores().clear();
|
data.getScores().clear();
|
||||||
@ -107,7 +108,7 @@ public class MatchService {
|
|||||||
|
|
||||||
public Uni<?> delete(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
public Uni<?> delete(SecurityCtx securityCtx, CompetitionSystem system, Long id) {
|
||||||
return repository.find("systemId = ?1 AND system = ?2", id, system).firstResult()
|
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()))
|
.call(o2 -> permService.hasEditPerm(securityCtx, o2.getPoule().getCompet()))
|
||||||
.chain(data -> Panache.withTransaction(() -> repository.delete(data)));
|
.chain(data -> Panache.withTransaction(() -> repository.delete(data)));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,19 +48,19 @@ public class Utils {
|
|||||||
int birthYear = toCalendar(birth_date).get(Calendar.YEAR);
|
int birthYear = toCalendar(birth_date).get(Calendar.YEAR);
|
||||||
|
|
||||||
int diff = currentSaison - birthYear;
|
int diff = currentSaison - birthYear;
|
||||||
if (diff < 7) {
|
if (diff < 6) {
|
||||||
return Categorie.SUPER_MINI;
|
return Categorie.SUPER_MINI;
|
||||||
} else if (diff < 9) {
|
} else if (diff < 8) {
|
||||||
return Categorie.MINI_POUSSIN;
|
return Categorie.MINI_POUSSIN;
|
||||||
} else if (diff < 11) {
|
} else if (diff < 10) {
|
||||||
return Categorie.POUSSIN;
|
return Categorie.POUSSIN;
|
||||||
} else if (diff < 13) {
|
} else if (diff < 12) {
|
||||||
return Categorie.BENJAMIN;
|
return Categorie.BENJAMIN;
|
||||||
} else if (diff < 15) {
|
} else if (diff < 14) {
|
||||||
return Categorie.MINIME;
|
return Categorie.MINIME;
|
||||||
} else if (diff < 17) {
|
} else if (diff < 16) {
|
||||||
return Categorie.CADET;
|
return Categorie.CADET;
|
||||||
} else if (diff < 19) {
|
} else if (diff < 18) {
|
||||||
return Categorie.JUNIOR;
|
return Categorie.JUNIOR;
|
||||||
} else if (diff < 25) {
|
} else if (diff < 25) {
|
||||||
return Categorie.SENIOR1;
|
return Categorie.SENIOR1;
|
||||||
|
|||||||
@ -17,19 +17,19 @@ export function getCategoryFormBirthDate(birth_date, currentDate = new Date()) {
|
|||||||
const birthYear = birth_date.getFullYear()
|
const birthYear = birth_date.getFullYear()
|
||||||
|
|
||||||
const diff = currentSaison - birthYear;
|
const diff = currentSaison - birthYear;
|
||||||
if (diff < 7) {
|
if (diff < 6) {
|
||||||
return "SUPER_MINI";
|
return "SUPER_MINI";
|
||||||
} else if (diff < 9) {
|
} else if (diff < 8) {
|
||||||
return "MINI_POUSSIN";
|
return "MINI_POUSSIN";
|
||||||
} else if (diff < 11) {
|
} else if (diff < 10) {
|
||||||
return "POUSSIN";
|
return "POUSSIN";
|
||||||
} else if (diff < 13) {
|
} else if (diff < 12) {
|
||||||
return "BENJAMIN";
|
return "BENJAMIN";
|
||||||
} else if (diff < 15) {
|
} else if (diff < 14) {
|
||||||
return "MINIME";
|
return "MINIME";
|
||||||
} else if (diff < 17) {
|
} else if (diff < 16) {
|
||||||
return "CADET";
|
return "CADET";
|
||||||
} else if (diff < 19) {
|
} else if (diff < 18) {
|
||||||
return "JUNIOR";
|
return "JUNIOR";
|
||||||
} else if (diff < 25) {
|
} else if (diff < 25) {
|
||||||
return "SENIOR1";
|
return "SENIOR1";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user