dev #91

Merged
Thibaut merged 4 commits from dev into master 2026-01-02 14:06:10 +00:00
3 changed files with 25 additions and 12 deletions

View File

@ -115,13 +115,15 @@ public class ResultService {
public Uni<ResultCategoryData> getCategory(String uuid, long poule, SecurityCtx securityCtx) { public Uni<ResultCategoryData> getCategory(String uuid, long poule, SecurityCtx securityCtx) {
return hasAccess(uuid, securityCtx).chain(r -> return hasAccess(uuid, securityCtx).chain(r ->
matchRepository.list("category.compet.uuid = ?1 AND category.id = ?2", uuid, poule) matchRepository.list("category.compet.uuid = ?1 AND category.id = ?2", uuid, poule)
.call(list -> Mutiny.fetch(list.get(0).getCategory().getTree())) .call(list -> list.isEmpty() ? Uni.createFrom().voidItem() :
Mutiny.fetch(list.get(0).getCategory().getTree()))
.map(list -> getData(list, r.getMembre()))); .map(list -> getData(list, r.getMembre())));
} }
public Uni<ResultCategoryData> getCategory(String uuid, long poule) { public Uni<ResultCategoryData> getCategory(String uuid, long poule) {
return matchRepository.list("category.compet.uuid = ?1 AND category.id = ?2", uuid, poule) return matchRepository.list("category.compet.uuid = ?1 AND category.id = ?2", uuid, poule)
.call(list -> Mutiny.fetch(list.get(0).getCategory().getTree())) .call(list -> list.isEmpty() ? Uni.createFrom().voidItem() :
Mutiny.fetch(list.get(0).getCategory().getTree()))
.map(list -> getData(list, null)); .map(list -> getData(list, null));
} }

View File

@ -292,32 +292,43 @@ public class RMatch {
if (!o.getCompet().getUuid().equals(connection.pathParam("uuid"))) if (!o.getCompet().getUuid().equals(connection.pathParam("uuid")))
throw new DForbiddenException("Permission denied"); throw new DForbiddenException("Permission denied");
})) }))
.call(cm -> Panache.withTransaction( .invoke(m -> System.out.println("A00"))
() -> matchRepository.delete("id IN ?1 AND category = ?2", data.matchesToRemove, cm)) .call(cm -> data.matchesToRemove.isEmpty() ? Uni.createFrom().voidItem() :
.call(__ -> SSMatch.sendDeleteMatch(connection, data.matchesToRemove))) (Panache.withTransaction(
() -> matchRepository.delete("id IN ?1 AND category = ?2", data.matchesToRemove, cm))
.call(__ -> SSMatch.sendDeleteMatch(connection, data.matchesToRemove))))
.invoke(m -> System.out.println("A0"))
.call(cm -> Panache.withSession(() -> matchRepository.list("id IN ?1 AND category = ?2", .call(cm -> Panache.withSession(() -> matchRepository.list("id IN ?1 AND category = ?2",
Stream.concat(data.matchOrderToUpdate.keySet().stream(), Stream.concat(data.matchOrderToUpdate.keySet().stream(),
data.matchPouleToUpdate.keySet().stream()) data.matchPouleToUpdate.keySet().stream())
.distinct().toList(), cm) .distinct().toList(), cm)
.invoke(m -> System.out.println("A " + m.size()))
.invoke(matchModels -> matchModels.forEach(model -> { .invoke(matchModels -> matchModels.forEach(model -> {
if (data.matchPouleToUpdate.containsKey(model.getId())) if (data.matchPouleToUpdate.containsKey(model.getId()))
model.setPoule(data.matchPouleToUpdate.get(model.getId())); model.setPoule(data.matchPouleToUpdate.get(model.getId()));
if (data.matchOrderToUpdate.containsKey(model.getId())) if (data.matchOrderToUpdate.containsKey(model.getId()))
model.setCategory_ord(data.matchOrderToUpdate.get(model.getId())); model.setCategory_ord(data.matchOrderToUpdate.get(model.getId()));
})) }))
.call(mm -> Panache.withTransaction(() -> matchRepository.persist(mm))) .invoke(m -> System.out.println("B " + m.size()))
.call(mm -> mm.isEmpty() ? Uni.createFrom().voidItem() :
Panache.withTransaction(() -> matchRepository.persist(mm)))
.invoke(m -> System.out.println("C"))
.invoke(mm -> matches.addAll(mm.stream().map(MatchEntity::fromModel).toList()))) .invoke(mm -> matches.addAll(mm.stream().map(MatchEntity::fromModel).toList())))
) )
.invoke(m -> System.out.println("D"))
.chain(categoryModel -> { .chain(categoryModel -> {
Uni<List<MatchModel>> uni = Uni.createFrom().item(new ArrayList<>()); Uni<List<MatchModel>> uni = Uni.createFrom().item(new ArrayList<>());
for (AddMatch match : data.newMatch) for (AddMatch match : data.newMatch)
uni = uni.call(l -> creatMatch(categoryModel, match).invoke(l::add)); uni = uni.call(l -> creatMatch(categoryModel, match).invoke(l::add));
Uni<List<MatchModel>> finalUni = uni; Uni<List<MatchModel>> finalUni = uni;
return Panache.withSession(() -> finalUni); return Panache.withSession(() -> finalUni);
} }
) )
.chain(mm -> Panache.withTransaction(() -> matchRepository.create(mm)) .invoke(m -> System.out.println("E"))
.invoke(__ -> matches.addAll(mm.stream().map(MatchEntity::fromModel).toList()))) .chain(mm -> mm.isEmpty() ? Uni.createFrom().voidItem() :
Panache.withTransaction(() -> matchRepository.create(mm))
.invoke(__ -> matches.addAll(mm.stream().map(MatchEntity::fromModel).toList())))
.invoke(m -> System.out.println("F"))
.call(__ -> SSMatch.sendMatch(connection, matches)) .call(__ -> SSMatch.sendMatch(connection, matches))
.replaceWithVoid(); .replaceWithVoid();
} }

View File

@ -87,7 +87,7 @@ function CMTMatchPanel({catId, cat, menuActions}) {
setLoading(1); setLoading(1);
sendRequest('getFullCategory', catId) sendRequest('getFullCategory', catId)
.then((data) => { .then((data) => {
setTrees(data.trees.map(d => from_sendTree(d, true))) setTrees(data.trees.sort((a, b) => a.level - b.level).map(d => from_sendTree(d, true)))
let matches2 = []; let matches2 = [];
let combsToAdd = []; let combsToAdd = [];
@ -101,7 +101,7 @@ function CMTMatchPanel({catId, cat, menuActions}) {
const treeListener = ({data}) => { const treeListener = ({data}) => {
if (data.length < 1 || data[0].categorie !== catId) if (data.length < 1 || data[0].categorie !== catId)
return return
setTrees(data.map(d => from_sendTree(d, true))) setTrees(data.sort((a, b) => a.level - b.level).map(d => from_sendTree(d, true)))
let matches2 = []; let matches2 = [];
let combsToAdd = []; let combsToAdd = [];