feat: add config for preset in category + filter on select comb

This commit is contained in:
2026-02-05 23:53:49 +01:00
parent 7dab5b8880
commit 9954dd002c
9 changed files with 113 additions and 28 deletions

View File

@@ -1,5 +1,6 @@
package fr.titionfire.ffsaf.domain.entity;
import fr.titionfire.ffsaf.data.model.CatPresetModel;
import fr.titionfire.ffsaf.data.model.CompetitionGuestModel;
import fr.titionfire.ffsaf.data.model.MembreModel;
import fr.titionfire.ffsaf.data.model.RegisterModel;
@@ -28,6 +29,7 @@ public class CombEntity {
int overCategory;
Integer weight;
List<CombEntity> teamMembers;
List<Long> categoriesInscrites;
public static CombEntity fromModel(MembreModel model) {
if (model == null)
@@ -36,7 +38,7 @@ public class CombEntity {
return new CombEntity(model.getId(), model.getLname(), model.getFname(), model.getCategorie(),
model.getClub() == null ? null : model.getClub().getClubId(),
model.getClub() == null ? "Sans club" : model.getClub().getName(), model.getGenre(), model.getCountry(),
0, null, new ArrayList<>());
0, null, new ArrayList<>(), new ArrayList<>());
}
@@ -47,7 +49,15 @@ public class CombEntity {
return new CombEntity(model.getId() * -1, model.getLname(), model.getFname(), model.getCategorie(), null,
model.getClub(), model.getGenre(), model.getCountry(), 0, model.getWeight(),
Stream.concat(model.getComb().stream().map(CombEntity::fromModel),
model.getGuest().stream().map(CombEntity::fromModel)).toList());
model.getGuest().stream().map(CombEntity::fromModel)).toList(),
new ArrayList<>());
}
public CombEntity addCategoriesInscrites(List<CatPresetModel> categoriesInscrites) {
if (categoriesInscrites == null)
return this;
this.categoriesInscrites = categoriesInscrites.stream().map(CatPresetModel::getId).toList();
return this;
}
public static CombEntity fromModel(RegisterModel registerModel) {
@@ -58,6 +68,7 @@ public class CombEntity {
return new CombEntity(model.getId(), model.getLname(), model.getFname(), registerModel.getCategorie(),
registerModel.getClub2() == null ? null : registerModel.getClub2().getClubId(),
registerModel.getClub2() == null ? "Sans club" : registerModel.getClub2().getName(), model.getGenre(),
model.getCountry(), registerModel.getOverCategory(), registerModel.getWeight(), new ArrayList<>());
model.getCountry(), registerModel.getOverCategory(), registerModel.getWeight(), new ArrayList<>(),
new ArrayList<>());
}
}

View File

@@ -4,10 +4,12 @@ import fr.titionfire.ffsaf.data.model.CatPresetModel;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@RegisterForReflection
public class PresetData {

View File

@@ -250,6 +250,12 @@ public class RCategorie {
.replaceWithVoid();
}
@WSReceiver(code = "listPreset", permission = PermLevel.VIEW)
public Uni<List<PresetData>> listPreset(WebSocketConnection connection, Object o) {
return catPresetRepository.list("competition.uuid", connection.pathParam("uuid"))
.map(presets -> presets.stream().map(PresetData::fromModel).toList());
}
@WSReceiver(code = "createClassementMatchs", permission = PermLevel.TABLE)
public Uni<Void> createClassementMatchs(WebSocketConnection connection, Long categoryId) {
return getById(categoryId, connection)

View File

@@ -6,6 +6,7 @@ import fr.titionfire.ffsaf.ws.PermLevel;
import io.quarkus.hibernate.reactive.panache.common.WithSession;
import io.quarkus.runtime.annotations.RegisterForReflection;
import io.quarkus.websockets.next.WebSocketConnection;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -24,14 +25,20 @@ public class RRegister {
@WSReceiver(code = "getRegister", permission = PermLevel.TABLE)
public Uni<List<CombEntity>> getRegister(WebSocketConnection connection, Object o) {
ArrayList<CombEntity> combEntities = new ArrayList<>();
return competitionRepository.find("uuid", connection.pathParam("uuid")).firstResult()
.call(cm -> Mutiny.fetch(cm.getInsc()))
.call(cm -> Mutiny.fetch(cm.getGuests()))
.map(cm -> {
ArrayList<CombEntity> combEntities = new ArrayList<>();
combEntities.addAll(cm.getInsc().stream().map(CombEntity::fromModel).toList());
combEntities.addAll(cm.getGuests().stream().map(CombEntity::fromModel).toList());
return combEntities;
});
.call(cm -> Mutiny.fetch(cm.getInsc())
.onItem().transformToMulti(Multi.createFrom()::iterable)
.call(r -> Mutiny.fetch(r.getCategoriesInscrites()))
.map(r -> CombEntity.fromModel(r).addCategoriesInscrites(r.getCategoriesInscrites()))
.collect().asList()
.invoke(combEntities::addAll))
.call(cm -> Mutiny.fetch(cm.getGuests())
.onItem().transformToMulti(Multi.createFrom()::iterable)
.call(r -> Mutiny.fetch(r.getCategoriesInscrites()))
.map(r -> CombEntity.fromModel(r).addCategoriesInscrites(r.getCategoriesInscrites()))
.collect().asList()
.invoke(combEntities::addAll))
.replaceWith(combEntities);
}
}

View File

@@ -14,6 +14,7 @@ import io.quarkus.websockets.next.UserData;
import io.smallrye.mutiny.Uni;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.hibernate.reactive.mutiny.Mutiny;
import java.util.List;
import java.util.UUID;
@@ -30,18 +31,20 @@ public class SRegister {
CardService cardService;
public Uni<Void> sendRegister(String uuid, RegisterModel registerModel) {
return send(uuid, "sendRegister", CombEntity.fromModel(registerModel))
.call(__ -> cardService.addTeamCartToNewComb(registerModel.getMembre().getId(),
registerModel.getClub2().getClubId(), registerModel.getClub2().getName(),
registerModel.getCompetition())
.chain(cardModels -> send(uuid, "sendCards", cardModels)));
return Mutiny.fetch(registerModel.getCategoriesInscrites()).chain(o ->
send(uuid, "sendRegister", CombEntity.fromModel(registerModel).addCategoriesInscrites(o))
.call(__ -> cardService.addTeamCartToNewComb(registerModel.getMembre().getId(),
registerModel.getClub2().getClubId(), registerModel.getClub2().getName(),
registerModel.getCompetition())
.chain(cardModels -> send(uuid, "sendCards", cardModels))));
}
public Uni<Void> sendRegister(String uuid, CompetitionGuestModel model) {
return send(uuid, "sendRegister", CombEntity.fromModel(model))
.call(__ -> cardService.addTeamCartToNewComb(model.getId() * -1,
null, model.getClub(), model.getCompetition())
.chain(cardModels -> send(uuid, "sendCards", cardModels)));
return Mutiny.fetch(model.getCategoriesInscrites()).chain(o ->
send(uuid, "sendRegister", CombEntity.fromModel(model).addCategoriesInscrites(o))
.call(__ -> cardService.addTeamCartToNewComb(model.getId() * -1,
null, model.getClub(), model.getCompetition())
.chain(cardModels -> send(uuid, "sendCards", cardModels))));
}
public Uni<Void> sendRegisterRemove(String uuid, Long combId) {