Compare commits
No commits in common. "13bae3e81754b153def077db5335487f79d8a87c" and "3d07a5bc8e9ca94ff19cdd31e3dd43f0ce5d7c25" have entirely different histories.
13bae3e817
...
3d07a5bc8e
@ -1,9 +0,0 @@
|
|||||||
package fr.titionfire.ffsaf.data.model;
|
|
||||||
|
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
|
|
||||||
public interface CombModel {
|
|
||||||
Long getCombId();
|
|
||||||
String getName();
|
|
||||||
String getName(MembreModel model, ResultPrivacy privacy);
|
|
||||||
}
|
|
||||||
@ -2,7 +2,6 @@ package fr.titionfire.ffsaf.data.model;
|
|||||||
|
|
||||||
import fr.titionfire.ffsaf.utils.Categorie;
|
import fr.titionfire.ffsaf.utils.Categorie;
|
||||||
import fr.titionfire.ffsaf.utils.Genre;
|
import fr.titionfire.ffsaf.utils.Genre;
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -18,7 +17,7 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "competition_guest")
|
@Table(name = "competition_guest")
|
||||||
public class CompetitionGuestModel implements CombModel {
|
public class CompetitionGuestModel {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
Long id;
|
Long id;
|
||||||
@ -45,18 +44,7 @@ public class CompetitionGuestModel implements CombModel {
|
|||||||
this.lname = s.substring(s.indexOf(" ") + 1);
|
this.lname = s.substring(s.indexOf(" ") + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getCombId() {
|
|
||||||
return this.id * -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.fname + " " + this.lname;
|
return fname + " " + lname;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName(MembreModel model, ResultPrivacy privacy) {
|
|
||||||
return getName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package fr.titionfire.ffsaf.data.model;
|
package fr.titionfire.ffsaf.data.model;
|
||||||
|
|
||||||
import fr.titionfire.ffsaf.utils.CompetitionSystem;
|
import fr.titionfire.ffsaf.utils.CompetitionSystem;
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@ -10,7 +9,6 @@ import lombok.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -67,35 +65,19 @@ public class MatchModel {
|
|||||||
@JoinColumn(name = "match", referencedColumnName = "id")
|
@JoinColumn(name = "match", referencedColumnName = "id")
|
||||||
List<CardboardModel> cardboard = new ArrayList<>();
|
List<CardboardModel> cardboard = new ArrayList<>();
|
||||||
|
|
||||||
public String getC1Name(MembreModel model, ResultPrivacy privacy) {
|
|
||||||
if (c1_id != null)
|
|
||||||
return c1_id.getName(model, privacy);
|
|
||||||
if (c1_guest != null)
|
|
||||||
return c1_guest.getName(model, privacy);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getC2Name(MembreModel model, ResultPrivacy privacy) {
|
|
||||||
if (c2_id != null)
|
|
||||||
return c2_id.getName(model, privacy);
|
|
||||||
if (c2_guest != null)
|
|
||||||
return c2_guest.getName(model, privacy);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getC1Name() {
|
public String getC1Name() {
|
||||||
if (c1_id != null)
|
if (c1_id != null)
|
||||||
return c1_id.getName();
|
return c1_id.fname + " " + c1_id.lname;
|
||||||
if (c1_guest != null)
|
if (c1_guest != null)
|
||||||
return c1_guest.getName();
|
return c1_guest.fname + " " + c1_guest.lname;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getC2Name() {
|
public String getC2Name() {
|
||||||
if (c2_id != null)
|
if (c2_id != null)
|
||||||
return c2_id.getName();
|
return c2_id.fname + " " + c2_id.lname;
|
||||||
if (c2_guest != null)
|
if (c2_guest != null)
|
||||||
return c2_guest.getName();
|
return c2_guest.fname + " " + c2_guest.lname;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,24 +94,4 @@ public class MatchModel {
|
|||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isC1(Object comb) {
|
|
||||||
if (comb instanceof Long id_) {
|
|
||||||
if (id_ >= 0)
|
|
||||||
return Objects.equals(this.c1_id != null ? this.c1_id.getId() : null, id_);
|
|
||||||
else
|
|
||||||
return Objects.equals(this.c1_guest != null ? this.c1_guest.getId() : null, -id_);
|
|
||||||
}
|
|
||||||
return Objects.equals(this.c1_id, comb) || Objects.equals(this.c1_guest, comb);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isC2(Object comb) {
|
|
||||||
if (comb instanceof Long id_) {
|
|
||||||
if (id_ >= 0)
|
|
||||||
return Objects.equals(this.c2_id != null ? this.c2_id.getId() : null, id_);
|
|
||||||
else
|
|
||||||
return Objects.equals(this.c2_guest != null ? this.c2_guest.getId() : null, -id_);
|
|
||||||
}
|
|
||||||
return Objects.equals(this.c2_id, comb) || Objects.equals(this.c2_guest, comb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package fr.titionfire.ffsaf.data.model;
|
package fr.titionfire.ffsaf.data.model;
|
||||||
|
|
||||||
import fr.titionfire.ffsaf.utils.*;
|
import fr.titionfire.ffsaf.utils.Categorie;
|
||||||
|
import fr.titionfire.ffsaf.utils.Genre;
|
||||||
|
import fr.titionfire.ffsaf.utils.GradeArbitrage;
|
||||||
|
import fr.titionfire.ffsaf.utils.RoleAsso;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
@ -8,7 +11,6 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -19,23 +21,23 @@ import java.util.Objects;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "membre")
|
@Table(name = "membre")
|
||||||
public class MembreModel implements LoggableModel, CombModel {
|
public class MembreModel implements LoggableModel {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Access(AccessType.PROPERTY)
|
@Access(AccessType.PROPERTY)
|
||||||
@Schema(description = "L'identifiant du membre.", examples = "1")
|
@Schema(description = "L'identifiant du membre.", example = "1")
|
||||||
Long id;
|
Long id;
|
||||||
|
|
||||||
@Schema(description = "L'identifiant long du membre (userID).", examples = "e81d1d35-d897-421e-8086-6c5e74d13c6e")
|
@Schema(description = "L'identifiant long du membre (userID).", example = "e81d1d35-d897-421e-8086-6c5e74d13c6e")
|
||||||
String userId;
|
String userId;
|
||||||
|
|
||||||
@Schema(description = "Le nom du membre.", examples = "Dupont")
|
@Schema(description = "Le nom du membre.", example = "Dupont")
|
||||||
String lname;
|
String lname;
|
||||||
@Schema(description = "Le prénom du membre.", examples = "Jean")
|
@Schema(description = "Le prénom du membre.", example = "Jean")
|
||||||
String fname;
|
String fname;
|
||||||
|
|
||||||
@Schema(description = "La catégorie du membre.", examples = "SENIOR")
|
@Schema(description = "La catégorie du membre.", example = "SENIOR")
|
||||||
Categorie categorie;
|
Categorie categorie;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@ -43,30 +45,29 @@ public class MembreModel implements LoggableModel, CombModel {
|
|||||||
@Schema(description = "Le club du membre.")
|
@Schema(description = "Le club du membre.")
|
||||||
ClubModel club;
|
ClubModel club;
|
||||||
|
|
||||||
@Schema(description = "Le genre du membre.", examples = "H")
|
@Schema(description = "Le genre du membre.", example = "H")
|
||||||
Genre genre;
|
Genre genre;
|
||||||
|
|
||||||
@Schema(description = "Le numéro de licence du membre.", examples = "12345")
|
@Schema(description = "Le numéro de licence du membre.", example = "12345")
|
||||||
Integer licence;
|
Integer licence;
|
||||||
|
|
||||||
@Schema(description = "Le pays du membre.", examples = "FR")
|
@Schema(description = "Le pays du membre.", example = "FR")
|
||||||
String country;
|
String country;
|
||||||
|
|
||||||
@Schema(description = "La date de naissance du membre.")
|
@Schema(description = "La date de naissance du membre.")
|
||||||
Date birth_date;
|
Date birth_date;
|
||||||
|
|
||||||
@Schema(description = "L'adresse e-mail du membre.", examples = "jean.dupont@examples.com")
|
@Schema(description = "L'adresse e-mail du membre.", example = "jean.dupont@example.com")
|
||||||
String email;
|
String email;
|
||||||
|
|
||||||
@Schema(description = "Le rôle du membre dans l'association.", examples = "MEMBRE")
|
@Schema(description = "Le rôle du membre dans l'association.", example = "MEMBRE")
|
||||||
RoleAsso role;
|
RoleAsso role;
|
||||||
|
|
||||||
@Schema(description = "Le grade d'arbitrage du membre.", examples = "NA")
|
@Schema(description = "Le grade d'arbitrage du membre.", example = "NA")
|
||||||
GradeArbitrage grade_arbitrage;
|
GradeArbitrage grade_arbitrage;
|
||||||
|
|
||||||
@Schema(description = "La confidentialité de ces résultats", examples = "PUBLIC")
|
@Schema(hidden = true)
|
||||||
@Column(nullable = false, columnDefinition = "smallint default 0")
|
String url_photo;
|
||||||
ResultPrivacy resultPrivacy = ResultPrivacy.PUBLIC;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "membre", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "membre", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||||
@Schema(description = "Les licences du membre. (optionnel)")
|
@Schema(description = "Les licences du membre. (optionnel)")
|
||||||
@ -99,25 +100,4 @@ public class MembreModel implements LoggableModel, CombModel {
|
|||||||
", grade_arbitrage=" + grade_arbitrage +
|
", grade_arbitrage=" + grade_arbitrage +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getCombId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return this.fname + " " + this.lname;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName(MembreModel model, ResultPrivacy privacy) {
|
|
||||||
if (model == null || !Objects.equals(this.getId(), model.getId())) {
|
|
||||||
if (model == null && this.getResultPrivacy() != ResultPrivacy.PUBLIC)
|
|
||||||
return "Anonyme";
|
|
||||||
if (this.getResultPrivacy().ordinal() > privacy.ordinal())
|
|
||||||
return "Anonyme";
|
|
||||||
}
|
|
||||||
return getName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,64 @@
|
|||||||
|
package fr.titionfire.ffsaf.domain.entity;
|
||||||
|
|
||||||
|
import fr.titionfire.ffsaf.data.model.MembreModel;
|
||||||
|
import fr.titionfire.ffsaf.utils.Categorie;
|
||||||
|
import fr.titionfire.ffsaf.utils.Genre;
|
||||||
|
import fr.titionfire.ffsaf.utils.GradeArbitrage;
|
||||||
|
import fr.titionfire.ffsaf.utils.RoleAsso;
|
||||||
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@RegisterForReflection
|
||||||
|
public class MembreEntity {
|
||||||
|
private long id;
|
||||||
|
private String lname = "";
|
||||||
|
private String fname = "";
|
||||||
|
private Categorie categorie;
|
||||||
|
private ClubEntity club;
|
||||||
|
private Genre genre;
|
||||||
|
private Integer licence;
|
||||||
|
private String country;
|
||||||
|
private Date birth_date;
|
||||||
|
private String email;
|
||||||
|
private RoleAsso role;
|
||||||
|
private GradeArbitrage grade_arbitrage;
|
||||||
|
private String url_photo;
|
||||||
|
|
||||||
|
|
||||||
|
public static MembreEntity fromModel(MembreModel model) {
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new MembreEntityBuilder()
|
||||||
|
.id(model.getId())
|
||||||
|
.lname(model.getLname())
|
||||||
|
.fname(model.getFname())
|
||||||
|
.categorie(model.getCategorie())
|
||||||
|
.club(ClubEntity.fromModel(model.getClub()))
|
||||||
|
.genre(model.getGenre())
|
||||||
|
.licence(model.getLicence())
|
||||||
|
.country(model.getCountry())
|
||||||
|
.birth_date(model.getBirth_date())
|
||||||
|
.email(model.getEmail())
|
||||||
|
.role(model.getRole())
|
||||||
|
.grade_arbitrage(model.getGrade_arbitrage())
|
||||||
|
.url_photo(model.getUrl_photo())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFullName(MembreModel model) {
|
||||||
|
return model.getFname() + " " + model.getLname();
|
||||||
|
}
|
||||||
|
public String getFullName() {
|
||||||
|
return this.fname + " " + this.lname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -292,8 +292,7 @@ public class ClubService {
|
|||||||
Uni.join().all(list.stream().filter(m -> m.getUserId() != null)
|
Uni.join().all(list.stream().filter(m -> m.getUserId() != null)
|
||||||
.map(m -> keycloakService.clearUser(m.getUserId())).toList())
|
.map(m -> keycloakService.clearUser(m.getUserId())).toList())
|
||||||
.andCollectFailures())
|
.andCollectFailures())
|
||||||
.chain(list -> list.isEmpty() ? Uni.createFrom().voidItem() :
|
.chain(list -> Panache.withTransaction(() -> combRepository.persist(list)))
|
||||||
Panache.withTransaction(() -> combRepository.persist(list)))
|
|
||||||
.map(o -> club)
|
.map(o -> club)
|
||||||
)
|
)
|
||||||
.call(clubModel -> (clubModel.getClubId() == null) ? Uni.createFrom()
|
.call(clubModel -> (clubModel.getClubId() == null) ? Uni.createFrom()
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import fr.titionfire.ffsaf.rest.exception.DBadRequestException;
|
|||||||
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
||||||
import fr.titionfire.ffsaf.rest.exception.DInternalError;
|
import fr.titionfire.ffsaf.rest.exception.DInternalError;
|
||||||
import fr.titionfire.ffsaf.rest.from.FullMemberForm;
|
import fr.titionfire.ffsaf.rest.from.FullMemberForm;
|
||||||
import fr.titionfire.ffsaf.rest.from.UserSettingForm;
|
|
||||||
import fr.titionfire.ffsaf.utils.*;
|
import fr.titionfire.ffsaf.utils.*;
|
||||||
import io.quarkus.hibernate.reactive.panache.Panache;
|
import io.quarkus.hibernate.reactive.panache.Panache;
|
||||||
import io.quarkus.hibernate.reactive.panache.PanacheQuery;
|
import io.quarkus.hibernate.reactive.panache.PanacheQuery;
|
||||||
@ -468,8 +467,7 @@ public class MembreService {
|
|||||||
.call(membreModel -> licenceRepository.update("club_id = ?1 where membre = ?2 AND saison = ?3",
|
.call(membreModel -> licenceRepository.update("club_id = ?1 where membre = ?2 AND saison = ?3",
|
||||||
(membreModel.getClub() == null) ? null : membreModel.getClub().getId(), membreModel,
|
(membreModel.getClub() == null) ? null : membreModel.getClub().getId(), membreModel,
|
||||||
Utils.getSaison()))
|
Utils.getSaison()))
|
||||||
.call(membreModel -> (membre.getPhoto_data() != null && membre.getPhoto_data()
|
.call(membreModel -> (membre.getPhoto_data() != null && membre.getPhoto_data().size() > 0) ? ls.logAUpdate("Photo",
|
||||||
.size() > 0) ? ls.logAUpdate("Photo",
|
|
||||||
membreModel) : Uni.createFrom().nullItem())
|
membreModel) : Uni.createFrom().nullItem())
|
||||||
.map(__ -> "OK");
|
.map(__ -> "OK");
|
||||||
}
|
}
|
||||||
@ -595,20 +593,6 @@ public class MembreService {
|
|||||||
.map(__ -> meData);
|
.map(__ -> meData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<Void> updateSettings(String subject, UserSettingForm settingForm) {
|
|
||||||
return repository.find("userId = ?1", subject).firstResult()
|
|
||||||
.invoke(Unchecked.consumer(membreModel -> {
|
|
||||||
if (settingForm.getResultPrivacy() != null) {
|
|
||||||
ls.logChange("Confidentialité des résultats", membreModel.getResultPrivacy(),
|
|
||||||
settingForm.getResultPrivacy(), membreModel);
|
|
||||||
membreModel.setResultPrivacy(settingForm.getResultPrivacy());
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.call(membreModel -> Panache.withTransaction(() -> repository.persist(membreModel)))
|
|
||||||
.call(membreModel -> ls.append())
|
|
||||||
.replaceWithVoid();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 1 1 9 ?")
|
@Scheduled(cron = "0 0 1 1 9 ?")
|
||||||
Uni<Void> everySeason() {
|
Uni<Void> everySeason() {
|
||||||
return repository.list("birth_date IS NOT NULL")
|
return repository.list("birth_date IS NOT NULL")
|
||||||
@ -618,4 +602,5 @@ public class MembreService {
|
|||||||
}).toList()).andCollectFailures())
|
}).toList()).andCollectFailures())
|
||||||
.map(__ -> null);
|
.map(__ -> null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package fr.titionfire.ffsaf.domain.service;
|
|||||||
import fr.titionfire.ffsaf.data.model.*;
|
import fr.titionfire.ffsaf.data.model.*;
|
||||||
import fr.titionfire.ffsaf.data.repository.*;
|
import fr.titionfire.ffsaf.data.repository.*;
|
||||||
import fr.titionfire.ffsaf.rest.data.ResultCategoryData;
|
import fr.titionfire.ffsaf.rest.data.ResultCategoryData;
|
||||||
import fr.titionfire.ffsaf.rest.exception.DBadRequestException;
|
|
||||||
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
||||||
import fr.titionfire.ffsaf.utils.*;
|
import fr.titionfire.ffsaf.utils.*;
|
||||||
import io.quarkus.hibernate.reactive.panache.common.WithSession;
|
import io.quarkus.hibernate.reactive.panache.common.WithSession;
|
||||||
@ -17,7 +16,9 @@ import lombok.Builder;
|
|||||||
import org.hibernate.reactive.mutiny.Mutiny;
|
import org.hibernate.reactive.mutiny.Mutiny;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@WithSession
|
@WithSession
|
||||||
@ -47,50 +48,6 @@ public class ResultService {
|
|||||||
|
|
||||||
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("lang.String");
|
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("lang.String");
|
||||||
|
|
||||||
private static final HashMap<Long, String> combTempIds = new HashMap<>();
|
|
||||||
|
|
||||||
private static String getCombTempId(Long key) {
|
|
||||||
synchronized (combTempIds) {
|
|
||||||
if (!combTempIds.containsKey(key)) {
|
|
||||||
combTempIds.put(key, UUID.randomUUID().toString());
|
|
||||||
}
|
|
||||||
return combTempIds.get(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Long getCombTempId(String value) {
|
|
||||||
synchronized (combTempIds) {
|
|
||||||
for (Map.Entry<Long, String> entry : combTempIds.entrySet()) {
|
|
||||||
if (entry.getValue().equals(value)) {
|
|
||||||
return entry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HashMap<String, Long> clubTempIds = new HashMap<>();
|
|
||||||
|
|
||||||
private static Long getClubTempId(String key) {
|
|
||||||
synchronized (clubTempIds) {
|
|
||||||
if (!clubTempIds.containsKey(key)) {
|
|
||||||
clubTempIds.put(key, (System.currentTimeMillis() + clubTempIds.size()) * -1);
|
|
||||||
}
|
|
||||||
return clubTempIds.get(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getClubTempId(Long value) {
|
|
||||||
synchronized (clubTempIds) {
|
|
||||||
for (Map.Entry<String, Long> entry : clubTempIds.entrySet()) {
|
|
||||||
if (entry.getValue().equals(value)) {
|
|
||||||
return entry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Uni<List<Object[]>> getList(SecurityCtx securityCtx) {
|
public Uni<List<Object[]>> getList(SecurityCtx securityCtx) {
|
||||||
return membreService.getByAccountId(securityCtx.getSubject())
|
return membreService.getByAccountId(securityCtx.getSubject())
|
||||||
.chain(m -> registerRepository.list("membre = ?1", m))
|
.chain(m -> registerRepository.list("membre = ?1", m))
|
||||||
@ -112,20 +69,31 @@ public class ResultService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<ResultCategoryData> getCategory(String uuid, long poule, SecurityCtx securityCtx) {
|
public Uni<List<ResultCategoryData>> getCategory(String uuid, SecurityCtx securityCtx) {
|
||||||
return hasAccess(uuid, securityCtx).chain(r ->
|
return hasAccess(uuid, securityCtx)
|
||||||
matchRepository.list("category.compet.uuid = ?1 AND category.id = ?2", uuid, poule)
|
.chain(m -> categoryRepository.list("compet.uuid = ?1", uuid)
|
||||||
.call(list -> Mutiny.fetch(list.get(0).getCategory().getTree()))
|
.chain(cats -> matchRepository.list(
|
||||||
.map(list -> getData(list, r.getMembre())));
|
"(c1_id = ?1 OR c2_id = ?1 OR True) AND category IN ?2", //TODO rm OR True
|
||||||
|
m.getMembre(), cats)))
|
||||||
|
.map(matchModels -> {
|
||||||
|
HashMap<Long, List<MatchModel>> map = new HashMap<>();
|
||||||
|
for (MatchModel matchModel : matchModels) {
|
||||||
|
if (!map.containsKey(matchModel.getCategory().getId()))
|
||||||
|
map.put(matchModel.getCategory().getId(), new ArrayList<>());
|
||||||
|
map.get(matchModel.getCategory().getId()).add(matchModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map.values();
|
||||||
|
})
|
||||||
|
.onItem()
|
||||||
|
.transformToMulti(Multi.createFrom()::iterable)
|
||||||
|
.onItem().call(list -> Mutiny.fetch(list.get(0).getCategory().getTree()))
|
||||||
|
.onItem().transform(this::getData)
|
||||||
|
.collect().asList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<ResultCategoryData> getCategory(String uuid, long poule) {
|
private ResultCategoryData getData(List<MatchModel> matchModels) {
|
||||||
return matchRepository.list("category.compet.uuid = ?1 AND category.id = ?2", uuid, poule)
|
|
||||||
.call(list -> Mutiny.fetch(list.get(0).getCategory().getTree()))
|
|
||||||
.map(list -> getData(list, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResultCategoryData getData(List<MatchModel> matchModels, MembreModel membreModel) {
|
|
||||||
ResultCategoryData out = new ResultCategoryData();
|
ResultCategoryData out = new ResultCategoryData();
|
||||||
|
|
||||||
CategoryModel categoryModel = matchModels.get(0).getCategory();
|
CategoryModel categoryModel = matchModels.get(0).getCategory();
|
||||||
@ -134,12 +102,12 @@ public class ResultService {
|
|||||||
out.setLiceName(categoryModel.getLiceName() == null ? new String[]{} : categoryModel.getLiceName().split(";"));
|
out.setLiceName(categoryModel.getLiceName() == null ? new String[]{} : categoryModel.getLiceName().split(";"));
|
||||||
out.setGenTime(System.currentTimeMillis());
|
out.setGenTime(System.currentTimeMillis());
|
||||||
|
|
||||||
getArray2(matchModels, membreModel, out);
|
getArray2(matchModels, out);
|
||||||
getTree(categoryModel.getTree(), membreModel, out);
|
getTree(categoryModel.getTree(), out);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getArray2(List<MatchModel> matchModels_, MembreModel membreModel, ResultCategoryData out) {
|
private void getArray2(List<MatchModel> matchModels_, ResultCategoryData out) {
|
||||||
List<MatchModel> matchModels = matchModels_.stream().filter(o -> o.getCategory_ord() >= 0).toList();
|
List<MatchModel> matchModels = matchModels_.stream().filter(o -> o.getCategory_ord() >= 0).toList();
|
||||||
|
|
||||||
HashMap<Character, List<MatchModel>> matchMap = new HashMap<>();
|
HashMap<Character, List<MatchModel>> matchMap = new HashMap<>();
|
||||||
@ -153,30 +121,31 @@ public class ResultService {
|
|||||||
matchMap.forEach((c, matchEntities) -> {
|
matchMap.forEach((c, matchEntities) -> {
|
||||||
List<ResultCategoryData.PouleArrayData> matchs = matchEntities.stream()
|
List<ResultCategoryData.PouleArrayData> matchs = matchEntities.stream()
|
||||||
.sorted(Comparator.comparing(MatchModel::getCategory_ord))
|
.sorted(Comparator.comparing(MatchModel::getCategory_ord))
|
||||||
.map(o -> ResultCategoryData.PouleArrayData.fromModel(o, membreModel,
|
.map(ResultCategoryData.PouleArrayData::fromModel)
|
||||||
ResultPrivacy.REGISTERED_ONLY_NO_DETAILS))
|
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
List<ResultCategoryData.RankArray> rankArray = matchEntities.stream()
|
List<ResultCategoryData.RankArray> rankArray = matchEntities.stream()
|
||||||
.flatMap(m -> Stream.of(m.getC1_id(), m.getC2_id(), m.getC1_guest(), m.getC2_guest()))
|
.flatMap(m -> Stream.of(m.getC1Name(), m.getC2Name()))
|
||||||
.distinct()
|
.distinct()
|
||||||
.filter(Objects::nonNull)
|
.map(combName -> {
|
||||||
.map(comb -> {
|
|
||||||
AtomicInteger w = new AtomicInteger(0);
|
AtomicInteger w = new AtomicInteger(0);
|
||||||
AtomicInteger pointMake = new AtomicInteger(0);
|
AtomicInteger pointMake = new AtomicInteger(0);
|
||||||
AtomicInteger pointTake = new AtomicInteger(0);
|
AtomicInteger pointTake = new AtomicInteger(0);
|
||||||
|
|
||||||
matchEntities.stream()
|
matchEntities.stream()
|
||||||
.filter(m -> m.isEnd() && (m.isC1(comb) || m.isC2(comb)))
|
.filter(m -> m.isEnd() && (m.getC1Name().equals(combName) || m.getC2Name()
|
||||||
|
.equals(combName)))
|
||||||
.forEach(matchModel -> {
|
.forEach(matchModel -> {
|
||||||
int win = matchModel.win();
|
int win = matchModel.win();
|
||||||
if ((matchModel.isC1(comb) && win > 0) || matchModel.isC2(comb) && win < 0)
|
if ((matchModel.getC1Name()
|
||||||
|
.equals(combName) && win > 0) || matchModel.getC2Name()
|
||||||
|
.equals(combName) && win < 0)
|
||||||
w.getAndIncrement();
|
w.getAndIncrement();
|
||||||
|
|
||||||
for (ScoreEmbeddable score : matchModel.getScores()) {
|
for (ScoreEmbeddable score : matchModel.getScores()) {
|
||||||
if (score.getS1() <= -900 || score.getS2() <= -900)
|
if (score.getS1() <= -900 || score.getS2() <= -900)
|
||||||
continue;
|
continue;
|
||||||
if (matchModel.isC1(comb)) {
|
if (matchModel.getC1Name().equals(combName)) {
|
||||||
pointMake.addAndGet(score.getS1());
|
pointMake.addAndGet(score.getS1());
|
||||||
pointTake.addAndGet(score.getS2());
|
pointTake.addAndGet(score.getS2());
|
||||||
} else {
|
} else {
|
||||||
@ -187,8 +156,7 @@ public class ResultService {
|
|||||||
});
|
});
|
||||||
float pointRate = (pointTake.get() == 0) ? pointMake.get() : (float) pointMake.get() / pointTake.get();
|
float pointRate = (pointTake.get() == 0) ? pointMake.get() : (float) pointMake.get() / pointTake.get();
|
||||||
|
|
||||||
return new ResultCategoryData.RankArray(0,
|
return new ResultCategoryData.RankArray(0, combName, w.get(),
|
||||||
comb.getName(membreModel, ResultPrivacy.REGISTERED_ONLY_NO_DETAILS), w.get(),
|
|
||||||
pointMake.get(), pointTake.get(), pointRate);
|
pointMake.get(), pointTake.get(), pointRate);
|
||||||
})
|
})
|
||||||
.sorted(Comparator
|
.sorted(Comparator
|
||||||
@ -212,24 +180,29 @@ public class ResultService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void convertTree(TreeModel src, TreeNode<ResultCategoryData.TreeData> dst, MembreModel membreModel,
|
private static void convertTree(TreeModel src, TreeNode<ResultCategoryData.TreeData> dst) {
|
||||||
ResultPrivacy privacy) {
|
dst.setData(ResultCategoryData.TreeData.from(src.getMatch()));
|
||||||
dst.setData(ResultCategoryData.TreeData.from(src.getMatch(), membreModel, privacy));
|
|
||||||
if (src.getLeft() != null) {
|
if (src.getLeft() != null) {
|
||||||
dst.setLeft(new TreeNode<>());
|
dst.setLeft(new TreeNode<>());
|
||||||
convertTree(src.getLeft(), dst.getLeft(), membreModel, privacy);
|
convertTree(src.getLeft(), dst.getLeft());
|
||||||
}
|
}
|
||||||
if (src.getRight() != null) {
|
if (src.getRight() != null) {
|
||||||
dst.setRight(new TreeNode<>());
|
dst.setRight(new TreeNode<>());
|
||||||
convertTree(src.getRight(), dst.getRight(), membreModel, privacy);
|
convertTree(src.getRight(), dst.getRight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getTree(List<TreeModel> treeModels, MembreModel membreModel, ResultCategoryData out) {
|
public Uni<ResultCategoryData> getCategoryPublic(String uuid, long poule) {
|
||||||
|
return matchRepository.list("category.compet.uuid = ?1 AND category.id = ?2", uuid, poule)
|
||||||
|
.call(list -> Mutiny.fetch(list.get(0).getCategory().getTree()))
|
||||||
|
.map(this::getData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getTree(List<TreeModel> treeModels, ResultCategoryData out) {
|
||||||
ArrayList<TreeNode<ResultCategoryData.TreeData>> trees = new ArrayList<>();
|
ArrayList<TreeNode<ResultCategoryData.TreeData>> trees = new ArrayList<>();
|
||||||
treeModels.stream().filter(t -> t.getLevel() != 0).forEach(treeModel -> {
|
treeModels.stream().filter(t -> t.getLevel() != 0).forEach(treeModel -> {
|
||||||
TreeNode<ResultCategoryData.TreeData> root = new TreeNode<>();
|
TreeNode<ResultCategoryData.TreeData> root = new TreeNode<>();
|
||||||
convertTree(treeModel, root, membreModel, ResultPrivacy.REGISTERED_ONLY_NO_DETAILS);
|
convertTree(treeModel, root);
|
||||||
trees.add(root);
|
trees.add(root);
|
||||||
});
|
});
|
||||||
out.setTrees(trees);
|
out.setTrees(trees);
|
||||||
@ -237,14 +210,14 @@ public class ResultService {
|
|||||||
|
|
||||||
public Uni<CombsArrayData> getAllCombArray(String uuid, SecurityCtx securityCtx) {
|
public Uni<CombsArrayData> getAllCombArray(String uuid, SecurityCtx securityCtx) {
|
||||||
return hasAccess(uuid, securityCtx)
|
return hasAccess(uuid, securityCtx)
|
||||||
.chain(r -> getAllCombArray_(uuid, r.getMembre()));
|
.chain(__ -> getAllCombArray(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<CombsArrayData> getAllCombArrayPublic(String uuid) {
|
public Uni<CombsArrayData> getAllCombArrayPublic(String uuid) {
|
||||||
return getAllCombArray_(uuid, null);
|
return getAllCombArray(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Uni<CombsArrayData> getAllCombArray_(String uuid, MembreModel membreModel) {
|
public Uni<CombsArrayData> getAllCombArray(String uuid) {
|
||||||
return registerRepository.list("competition.uuid = ?1", uuid)
|
return registerRepository.list("competition.uuid = ?1", uuid)
|
||||||
.chain(registers -> matchRepository.list("category.compet.uuid = ?1", uuid)
|
.chain(registers -> matchRepository.list("category.compet.uuid = ?1", uuid)
|
||||||
.map(matchModels -> new Pair<>(registers, matchModels)))
|
.map(matchModels -> new Pair<>(registers, matchModels)))
|
||||||
@ -255,42 +228,57 @@ public class ResultService {
|
|||||||
CombsArrayData.CombsArrayDataBuilder builder = CombsArrayData.builder();
|
CombsArrayData.CombsArrayDataBuilder builder = CombsArrayData.builder();
|
||||||
|
|
||||||
List<CombsArrayData.CombsData> combs = matchModels.stream()
|
List<CombsArrayData.CombsData> combs = matchModels.stream()
|
||||||
.flatMap(m -> Stream.of(m.getC1_id(), m.getC2_id(), m.getC1_guest(), m.getC2_guest()))
|
.flatMap(m -> Stream.of(m.getC1Name(), m.getC2Name()))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.map(comb -> {
|
.map(combName -> {
|
||||||
var builder2 = CombsArrayData.CombsData.builder();
|
var builder2 = CombsArrayData.CombsData.builder();
|
||||||
AtomicInteger w = new AtomicInteger(0);
|
AtomicInteger w = new AtomicInteger(0);
|
||||||
AtomicInteger l = new AtomicInteger(0);
|
AtomicInteger l = new AtomicInteger(0);
|
||||||
AtomicInteger pointMake = new AtomicInteger();
|
AtomicInteger pointMake = new AtomicInteger();
|
||||||
AtomicInteger pointTake = new AtomicInteger();
|
AtomicInteger pointTake = new AtomicInteger();
|
||||||
|
|
||||||
makeStat(matchModels, comb, w, l, pointMake, pointTake);
|
matchModels.stream()
|
||||||
|
.filter(m -> m.isEnd() && (m.getC1Name().equals(combName)
|
||||||
|
|| m.getC2Name().equals(combName)))
|
||||||
|
.forEach(matchModel -> {
|
||||||
|
int win = matchModel.win();
|
||||||
|
if ((combName.equals(matchModel.getC1Name()) && win > 0) ||
|
||||||
|
combName.equals(matchModel.getC2Name()) && win < 0) {
|
||||||
|
w.getAndIncrement();
|
||||||
|
} else {
|
||||||
|
l.getAndIncrement();
|
||||||
|
}
|
||||||
|
|
||||||
|
matchModel.getScores().stream()
|
||||||
|
.filter(s -> s.getS1() > -900 && s.getS2() > -900)
|
||||||
|
.forEach(score -> {
|
||||||
|
if (combName.equals(matchModel.getC1Name())) {
|
||||||
|
pointMake.addAndGet(score.getS1());
|
||||||
|
pointTake.addAndGet(score.getS2());
|
||||||
|
} else {
|
||||||
|
pointMake.addAndGet(score.getS2());
|
||||||
|
pointTake.addAndGet(score.getS1());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Categorie categorie = null;
|
Categorie categorie = null;
|
||||||
String clubName = null;
|
ClubModel club = null;
|
||||||
|
|
||||||
Optional<RegisterModel> register = registers.stream()
|
Optional<RegisterModel> register = registers.stream()
|
||||||
.filter(r -> Objects.equals(r.getMembre(), comb)).findFirst();
|
.filter(r -> r.getName().equals(combName)).findFirst();
|
||||||
if (register.isPresent()) {
|
if (register.isPresent()) {
|
||||||
categorie = register.get().getCategorie2();
|
categorie = register.get().getCategorie();
|
||||||
ClubModel club = register.get().getClub2();
|
club = register.get().getClub2();
|
||||||
clubName = (club == null) ? BUNDLE.getString("no.licence") : club.getName();
|
|
||||||
} else if (comb instanceof CompetitionGuestModel guestModel) {
|
|
||||||
categorie = guestModel.getCategorie();
|
|
||||||
clubName = guestModel.getClub();
|
|
||||||
} else if (comb instanceof MembreModel model) {
|
|
||||||
categorie = model.getCategorie();
|
|
||||||
clubName = (model.getClub() == null) ? BUNDLE.getString(
|
|
||||||
"no.licence") : model.getClub().getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
builder2.cat((categorie == null) ? "---" : categorie.getName(BUNDLE));
|
builder2.cat((categorie == null) ? "---" : categorie.getName(BUNDLE));
|
||||||
builder2.name(comb.getName(membreModel, ResultPrivacy.REGISTERED_ONLY));
|
builder2.name(combName);
|
||||||
builder2.w(w.get());
|
builder2.w(w.get());
|
||||||
builder2.l(l.get());
|
builder2.l(l.get());
|
||||||
builder2.ratioVictoire((l.get() == 0) ? w.get() : (float) w.get() / l.get());
|
builder2.ratioVictoire((l.get() == 0) ? w.get() : (float) w.get() / l.get());
|
||||||
builder2.club(clubName);
|
builder2.club((club == null) ? BUNDLE.getString("no.licence") : club.getName());
|
||||||
builder2.pointMake(pointMake.get());
|
builder2.pointMake(pointMake.get());
|
||||||
builder2.pointTake(pointTake.get());
|
builder2.pointTake(pointTake.get());
|
||||||
builder2.ratioPoint(
|
builder2.ratioPoint(
|
||||||
@ -310,62 +298,62 @@ public class ResultService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<HashMap<String, String>> getCombList(String uuid, ResultPrivacy privacy) {
|
public Uni<HashMap<String, String>> getCombList(String uuid) {
|
||||||
return registerRepository.list("competition.uuid = ?1 AND membre.resultPrivacy <= ?2", uuid, privacy)
|
return registerRepository.list("competition.uuid = ?1", uuid)
|
||||||
.map(models -> {
|
.map(models -> {
|
||||||
HashMap<String, String> map = new HashMap<>();
|
HashMap<String, String> map = new HashMap<>();
|
||||||
models.forEach(
|
models.forEach(registerEmbeddable -> {
|
||||||
r -> map.put(Utils.getFullName(r.getMembre()), getCombTempId(r.getMembre().getId())));
|
map.put(Utils.getFullName(registerEmbeddable.getMembre()),
|
||||||
|
registerEmbeddable.getMembre().getFname() + "¤" + registerEmbeddable.getMembre()
|
||||||
|
.getLname());
|
||||||
|
});
|
||||||
return map;
|
return map;
|
||||||
})
|
})
|
||||||
.chain(map -> competitionGuestRepository.list("competition.uuid = ?1", uuid)
|
.chain(map -> competitionGuestRepository.list("competition.uuid = ?1", uuid)
|
||||||
.map(models -> {
|
.map(models -> {
|
||||||
models.forEach(guestModel -> map.put(Utils.getFullName(guestModel),
|
models.forEach(guestModel -> map.put(Utils.getFullName(guestModel),
|
||||||
getCombTempId(guestModel.getId() * -1)));
|
guestModel.getFname() + "¤" + guestModel.getLname()));
|
||||||
return map;
|
return map;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<?> getCombArrayPublic(String uuid, String combTempId, ResultPrivacy privacy) {
|
public Uni<?> getCombArrayPublic(String uuid, String fname, String lname) {
|
||||||
CombArrayData.CombArrayDataBuilder builder = CombArrayData.builder();
|
CombArrayData.CombArrayDataBuilder builder = CombArrayData.builder();
|
||||||
|
AtomicBoolean guest = new AtomicBoolean(false);
|
||||||
|
AtomicLong id = new AtomicLong(0);
|
||||||
|
|
||||||
Long id = getCombTempId(combTempId);
|
|
||||||
if (id == null) {
|
|
||||||
return Uni.createFrom().failure(new DForbiddenException("Comb not found"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Uni<List<MatchModel>> uni;
|
return registerRepository.find("membre.fname = ?1 AND membre.lname = ?2 AND competition.uuid = ?3", fname,
|
||||||
if (id >= 0) {
|
lname, uuid).firstResult()
|
||||||
uni = registerRepository.find("membre.id = ?1 AND competition.uuid = ?2 AND membre.resultPrivacy <= ?3", id,
|
.chain(registerModel -> {
|
||||||
uuid, privacy).firstResult()
|
if (registerModel == null) {
|
||||||
.chain(Unchecked.function(registerModel -> {
|
return competitionGuestRepository.find("fname = ?1 AND lname = ?2 AND competition.uuid = ?3",
|
||||||
if (registerModel == null)
|
fname, lname, uuid).firstResult()
|
||||||
throw new DBadRequestException("Combattant non inscrit");
|
.chain(guestModel -> {
|
||||||
|
builder.name(Utils.getFullName(guestModel));
|
||||||
|
builder.club(guestModel.getClub());
|
||||||
|
guest.set(true);
|
||||||
|
id.set(guestModel.getId());
|
||||||
|
builder.cat((guestModel.getCategorie() == null) ? "---" : guestModel.getCategorie()
|
||||||
|
.getName(BUNDLE));
|
||||||
|
|
||||||
builder.name(Utils.getFullName(registerModel.getMembre()));
|
return matchRepository.list(
|
||||||
builder.club((registerModel.getClub2() == null) ? BUNDLE.getString(
|
"category.compet.uuid = ?1 AND (c1_guest = ?2 OR c2_guest = ?2)", uuid,
|
||||||
"no.licence") : registerModel.getClub2().getName());
|
guestModel);
|
||||||
builder.cat((registerModel.getCategorie2() == null) ? "---" : registerModel.getCategorie2()
|
});
|
||||||
.getName(BUNDLE));
|
}
|
||||||
|
builder.name(Utils.getFullName(registerModel.getMembre()));
|
||||||
|
builder.club((registerModel.getClub2() == null) ? BUNDLE.getString(
|
||||||
|
"no.licence") : registerModel.getClub2().getName());
|
||||||
|
id.set(registerModel.getMembre().getId());
|
||||||
|
builder.cat((registerModel.getCategorie2() == null) ? "---" : registerModel.getCategorie2()
|
||||||
|
.getName(BUNDLE));
|
||||||
|
|
||||||
return matchRepository.list("category.compet.uuid = ?1 AND (c1_id = ?2 OR c2_id = ?2)", uuid,
|
return matchRepository.list("category.compet.uuid = ?1 AND (c1_id = ?2 OR c2_id = ?2)", uuid,
|
||||||
registerModel.getMembre());
|
registerModel.getMembre());
|
||||||
}));
|
})
|
||||||
} else {
|
.invoke(matchModels -> {
|
||||||
uni = competitionGuestRepository.find("id = ?1 AND competition.uuid = ?2", -id, uuid).firstResult()
|
|
||||||
.chain(guestModel -> {
|
|
||||||
builder.name(Utils.getFullName(guestModel));
|
|
||||||
builder.club(guestModel.getClub());
|
|
||||||
builder.cat((guestModel.getCategorie() == null) ? "---" : guestModel.getCategorie()
|
|
||||||
.getName(BUNDLE));
|
|
||||||
|
|
||||||
return matchRepository.list("category.compet.uuid = ?1 AND (c1_guest = ?2 OR c2_guest = ?2)",
|
|
||||||
uuid, guestModel);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return uni.invoke(matchModels -> {
|
|
||||||
List<CategoryModel> pouleModels = matchModels.stream().map(MatchModel::getCategory).distinct()
|
List<CategoryModel> pouleModels = matchModels.stream().map(MatchModel::getCategory).distinct()
|
||||||
.toList();
|
.toList();
|
||||||
List<CombArrayData.MatchsData> matchs = new ArrayList<>();
|
List<CombArrayData.MatchsData> matchs = new ArrayList<>();
|
||||||
@ -387,7 +375,9 @@ public class ResultService {
|
|||||||
AtomicInteger pointMake = new AtomicInteger();
|
AtomicInteger pointMake = new AtomicInteger();
|
||||||
AtomicInteger pointTake = new AtomicInteger();
|
AtomicInteger pointTake = new AtomicInteger();
|
||||||
|
|
||||||
if (matchModel.isC1(id)) {
|
if ((!guest.get() && matchModel.getC1_id() != null && matchModel.getC1_id().getId() == id.get())
|
||||||
|
|| (guest.get() && matchModel.getC1_guest() != null && matchModel.getC1_guest()
|
||||||
|
.getId() == id.get())) {
|
||||||
builder2.adv(Utils.getFullName(matchModel.getC2_id(), matchModel.getC2_guest()));
|
builder2.adv(Utils.getFullName(matchModel.getC2_id(), matchModel.getC2_guest()));
|
||||||
if (matchModel.isEnd()) {
|
if (matchModel.isEnd()) {
|
||||||
matchModel.getScores().stream()
|
matchModel.getScores().stream()
|
||||||
@ -466,141 +456,105 @@ public class ResultService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<HashMap<String, Long>> getClubList(String uuid) {
|
public Uni<HashMap<String, Long>> getClubList(String uuid) { // TODO add guest club
|
||||||
return registerRepository.list("competition.uuid = ?1", uuid)
|
return registerRepository.list("competition.uuid = ?1", uuid)
|
||||||
.map(registers -> {
|
.map(registers -> {
|
||||||
HashMap<String, Long> registerMap = new HashMap<>();
|
HashMap<String, Long> registerMap = new HashMap<>();
|
||||||
registers.stream().map(RegisterModel::getClub2).distinct().filter(Objects::nonNull)
|
registers.stream().map(RegisterModel::getClub2).distinct().filter(Objects::nonNull)
|
||||||
.forEach(registerClub -> registerMap.put(registerClub.getName(), registerClub.getId()));
|
.forEach(registerClub -> registerMap.put(registerClub.getName(), registerClub.getId()));
|
||||||
return registerMap;
|
return registerMap;
|
||||||
})
|
});
|
||||||
.chain(map -> competitionGuestRepository.list("competition.uuid = ?1", uuid)
|
|
||||||
.map(guests -> {
|
|
||||||
guests.stream().map(CompetitionGuestModel::getClub).distinct()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.forEach(guestClub -> map.putIfAbsent(guestClub,
|
|
||||||
getClubTempId(guestClub)));
|
|
||||||
return map;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<ClubArrayData> getClubArray(String uuid, Long id, SecurityCtx securityCtx) {
|
public Uni<ClubArrayData> getClubArray(String uuid, SecurityCtx securityCtx) {
|
||||||
return hasAccess(uuid, securityCtx).chain(cm_register -> getClubArray2(uuid, id, cm_register.getMembre()));
|
return hasAccess(uuid, securityCtx).chain(cm_register -> getClubArray(uuid, cm_register.getClub2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uni<ClubArrayData> getClubArray2(String uuid, Long id, MembreModel membreModel) {
|
public Uni<ClubArrayData> getClubArrayPublic(String uuid, Long id) {
|
||||||
if (id < 0) {
|
return clubRepository.findById(id).chain(clubModel -> getClubArray(uuid, clubModel));
|
||||||
String clubName = getClubTempId(id);
|
|
||||||
if (clubName == null) {
|
|
||||||
return Uni.createFrom().failure(new DForbiddenException("Club not found"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return competitionGuestRepository.list("competition.uuid = ?1 AND club = ?2", uuid, clubName)
|
|
||||||
.call(list -> {
|
|
||||||
if (list.isEmpty())
|
|
||||||
return Uni.createFrom().failure(new DBadRequestException("Club not found"));
|
|
||||||
return Uni.createFrom().voidItem();
|
|
||||||
})
|
|
||||||
.chain(guests -> matchRepository.list(
|
|
||||||
"category.compet.uuid = ?1 AND (c1_guest IN ?2 OR c2_guest IN ?2)", uuid, guests)
|
|
||||||
.map(matchModels ->
|
|
||||||
getClubArray2(clubName, guests.stream().map(o -> (CombModel) o).toList(),
|
|
||||||
matchModels, new ArrayList<>(), membreModel)));
|
|
||||||
} else {
|
|
||||||
return clubRepository.findById(id).chain(clubModel ->
|
|
||||||
registerRepository.list("competition.uuid = ?1 AND membre.club = ?2", uuid, clubModel)
|
|
||||||
.chain(registers -> matchRepository.list("category.compet.uuid = ?1", uuid)
|
|
||||||
.map(matchModels ->
|
|
||||||
getClubArray2(clubModel.getName(),
|
|
||||||
registers.stream().map(o -> (CombModel) o.getMembre()).toList(),
|
|
||||||
matchModels, registers, membreModel))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClubArrayData getClubArray2(String name, List<CombModel> combs, List<MatchModel> matchModels,
|
public Uni<ClubArrayData> getClubArray(String uuid, ClubModel clubModel) {
|
||||||
List<RegisterModel> registers, MembreModel membreModel) {
|
|
||||||
ClubArrayData.ClubArrayDataBuilder builder = ClubArrayData.builder();
|
ClubArrayData.ClubArrayDataBuilder builder = ClubArrayData.builder();
|
||||||
builder.name(name);
|
builder.name(clubModel.getName());
|
||||||
builder.nb_insc(combs.size());
|
|
||||||
|
|
||||||
AtomicInteger tt_win = new AtomicInteger(0);
|
return registerRepository.list("competition.uuid = ?1 AND membre.club = ?2", uuid, clubModel)
|
||||||
AtomicInteger tt_match = new AtomicInteger(0);
|
.chain(registers -> matchRepository.list("category.compet.uuid = ?1", uuid)
|
||||||
|
.map(matchModels -> new Pair<>(registers, matchModels)))
|
||||||
|
.map(pair -> {
|
||||||
|
List<RegisterModel> registers = pair.getKey();
|
||||||
|
List<MatchModel> matchModels = pair.getValue();
|
||||||
|
|
||||||
List<ClubArrayData.CombData> combData = combs.stream().map(comb -> {
|
builder.nb_insc(registers.size());
|
||||||
var builder2 = ClubArrayData.CombData.builder();
|
|
||||||
AtomicInteger w = new AtomicInteger(0);
|
|
||||||
AtomicInteger l = new AtomicInteger(0);
|
|
||||||
AtomicInteger pointMake = new AtomicInteger();
|
|
||||||
AtomicInteger pointTake = new AtomicInteger();
|
|
||||||
|
|
||||||
makeStat(matchModels, comb, w, l, pointMake, pointTake);
|
AtomicInteger tt_win = new AtomicInteger(0);
|
||||||
|
AtomicInteger tt_match = new AtomicInteger(0);
|
||||||
|
|
||||||
Categorie categorie = null;
|
List<ClubArrayData.CombData> combData = registers.stream().map(register -> {
|
||||||
|
var builder2 = ClubArrayData.CombData.builder();
|
||||||
|
AtomicInteger w = new AtomicInteger(0);
|
||||||
|
AtomicInteger l = new AtomicInteger(0);
|
||||||
|
AtomicInteger pointMake = new AtomicInteger();
|
||||||
|
AtomicInteger pointTake = new AtomicInteger();
|
||||||
|
|
||||||
Optional<RegisterModel> register = registers.stream()
|
matchModels.stream()
|
||||||
.filter(r -> Objects.equals(r.getMembre(), comb)).findFirst();
|
.filter(m -> m.isEnd() && (register.getMembre().equals(m.getC1_id())
|
||||||
if (register.isPresent()) {
|
|| register.getMembre().equals(m.getC2_id())))
|
||||||
categorie = register.get().getCategorie2();
|
.forEach(matchModel -> {
|
||||||
} else if (comb instanceof CompetitionGuestModel guestModel) {
|
int win = matchModel.win();
|
||||||
categorie = guestModel.getCategorie();
|
if ((register.getMembre().equals(matchModel.getC1_id()) && win > 0) ||
|
||||||
} else if (comb instanceof MembreModel model) {
|
register.getMembre().equals(matchModel.getC2_id()) && win < 0) {
|
||||||
categorie = model.getCategorie();
|
w.getAndIncrement();
|
||||||
}
|
} else {
|
||||||
|
l.getAndIncrement();
|
||||||
|
}
|
||||||
|
|
||||||
builder2.cat((categorie == null) ? "---" : categorie.getName(BUNDLE));
|
matchModel.getScores().stream()
|
||||||
builder2.name(comb.getName(membreModel, ResultPrivacy.REGISTERED_ONLY));
|
.filter(s -> s.getS1() > -900 && s.getS2() > -900)
|
||||||
builder2.w(w.get());
|
.forEach(score -> {
|
||||||
builder2.l(l.get());
|
if (register.getMembre().equals(matchModel.getC1_id())) {
|
||||||
builder2.ratioVictoire((l.get() == 0) ? w.get() : (float) w.get() / l.get());
|
pointMake.addAndGet(score.getS1());
|
||||||
builder2.pointMake(pointMake.get());
|
pointTake.addAndGet(score.getS2());
|
||||||
builder2.pointTake(pointTake.get());
|
} else {
|
||||||
builder2.ratioPoint((pointTake.get() == 0) ? pointMake.get() : (float) pointMake.get() / pointTake.get());
|
pointMake.addAndGet(score.getS2());
|
||||||
|
pointTake.addAndGet(score.getS1());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
tt_win.addAndGet(w.get());
|
Categorie categorie = register.getCategorie();
|
||||||
tt_match.addAndGet(w.get() + l.get());
|
if (categorie == null)
|
||||||
|
categorie = register.getMembre().getCategorie();
|
||||||
|
|
||||||
return builder2.build();
|
builder2.cat((categorie == null) ? "---" : categorie.getName(BUNDLE));
|
||||||
})
|
builder2.name(register.getName());
|
||||||
.sorted(Comparator.comparing(ClubArrayData.CombData::name))
|
builder2.w(w.get());
|
||||||
.toList();
|
builder2.l(l.get());
|
||||||
|
builder2.ratioVictoire((l.get() == 0) ? w.get() : (float) w.get() / l.get());
|
||||||
|
builder2.pointMake(pointMake.get());
|
||||||
|
builder2.pointTake(pointTake.get());
|
||||||
|
builder2.ratioPoint(
|
||||||
|
(pointTake.get() == 0) ? pointMake.get() : (float) pointMake.get() / pointTake.get());
|
||||||
|
|
||||||
builder.nb_match(tt_match.get());
|
tt_win.addAndGet(w.get());
|
||||||
builder.match_w(tt_win.get());
|
tt_match.addAndGet(w.get() + l.get());
|
||||||
builder.ratioVictoire((float) combData.stream().filter(c -> c.l + c.w != 0)
|
|
||||||
.mapToDouble(ClubArrayData.CombData::ratioVictoire).average().orElse(0L));
|
|
||||||
builder.pointMake(combData.stream().mapToInt(ClubArrayData.CombData::pointMake).sum());
|
|
||||||
builder.pointTake(combData.stream().mapToInt(ClubArrayData.CombData::pointTake).sum());
|
|
||||||
builder.ratioPoint((float) combData.stream().filter(c -> c.l + c.w != 0)
|
|
||||||
.mapToDouble(ClubArrayData.CombData::ratioPoint).average().orElse(0L));
|
|
||||||
builder.combs(combData);
|
|
||||||
|
|
||||||
return builder.build();
|
return builder2.build();
|
||||||
}
|
})
|
||||||
|
.sorted(Comparator.comparing(ClubArrayData.CombData::name))
|
||||||
|
.toList();
|
||||||
|
|
||||||
private static void makeStat(List<MatchModel> matchModels, CombModel comb, AtomicInteger w, AtomicInteger l,
|
builder.nb_match(tt_match.get());
|
||||||
AtomicInteger pointMake, AtomicInteger pointTake) {
|
builder.match_w(tt_win.get());
|
||||||
matchModels.stream()
|
builder.ratioVictoire((float) combData.stream().filter(c -> c.l + c.w != 0)
|
||||||
.filter(m -> m.isEnd() && (m.isC1(comb) || m.isC2(comb)))
|
.mapToDouble(ClubArrayData.CombData::ratioVictoire).average().orElse(0L));
|
||||||
.forEach(matchModel -> {
|
builder.pointMake(combData.stream().mapToInt(ClubArrayData.CombData::pointMake).sum());
|
||||||
int win = matchModel.win();
|
builder.pointTake(combData.stream().mapToInt(ClubArrayData.CombData::pointTake).sum());
|
||||||
if ((matchModel.isC1(comb) && win > 0) || matchModel.isC2(comb) && win < 0) {
|
builder.ratioPoint((float) combData.stream().filter(c -> c.l + c.w != 0)
|
||||||
w.getAndIncrement();
|
.mapToDouble(ClubArrayData.CombData::ratioPoint).average().orElse(0L));
|
||||||
} else {
|
builder.combs(combData);
|
||||||
l.getAndIncrement();
|
|
||||||
}
|
|
||||||
|
|
||||||
matchModel.getScores().stream()
|
return builder.build();
|
||||||
.filter(s -> s.getS1() > -900 && s.getS2() > -900)
|
|
||||||
.forEach(score -> {
|
|
||||||
if (matchModel.isC1(comb)) {
|
|
||||||
pointMake.addAndGet(score.getS1());
|
|
||||||
pointTake.addAndGet(score.getS2());
|
|
||||||
} else {
|
|
||||||
pointMake.addAndGet(score.getS2());
|
|
||||||
pointTake.addAndGet(score.getS1());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package fr.titionfire.ffsaf.rest;
|
|||||||
|
|
||||||
import fr.titionfire.ffsaf.domain.service.ResultService;
|
import fr.titionfire.ffsaf.domain.service.ResultService;
|
||||||
import fr.titionfire.ffsaf.domain.service.UpdateService;
|
import fr.titionfire.ffsaf.domain.service.UpdateService;
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
import io.smallrye.mutiny.Uni;
|
import io.smallrye.mutiny.Uni;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.ws.rs.*;
|
import jakarta.ws.rs.*;
|
||||||
@ -37,7 +36,7 @@ public class ExternalResultEndpoints {
|
|||||||
return Uni.createFrom().voidItem();
|
return Uni.createFrom().voidItem();
|
||||||
|
|
||||||
if (updateService.needUpdate(poule, rf)) {
|
if (updateService.needUpdate(poule, rf)) {
|
||||||
return resultService.getCategory(id, poule);
|
return resultService.getCategoryPublic(id, poule);
|
||||||
} else {
|
} else {
|
||||||
return Uni.createFrom().voidItem();
|
return Uni.createFrom().voidItem();
|
||||||
}
|
}
|
||||||
@ -47,7 +46,7 @@ public class ExternalResultEndpoints {
|
|||||||
@Path("/comb/list")
|
@Path("/comb/list")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Uni<HashMap<String, String>> combList() {
|
public Uni<HashMap<String, String>> combList() {
|
||||||
return resultService.getCombList(id, ResultPrivacy.PUBLIC);
|
return resultService.getCombList(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -56,7 +55,7 @@ public class ExternalResultEndpoints {
|
|||||||
public Uni<?> getArray(@QueryParam("comb") String comb) {
|
public Uni<?> getArray(@QueryParam("comb") String comb) {
|
||||||
if (comb.equals("0"))
|
if (comb.equals("0"))
|
||||||
return Uni.createFrom().item("");
|
return Uni.createFrom().item("");
|
||||||
return resultService.getCombArrayPublic(id, comb, ResultPrivacy.PUBLIC);
|
return resultService.getCombArrayPublic(id, comb.substring(0, comb.indexOf('¤')), comb.substring(comb.indexOf('¤') + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -67,6 +66,7 @@ public class ExternalResultEndpoints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/club/list")
|
@Path("/club/list")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@ -80,6 +80,6 @@ public class ExternalResultEndpoints {
|
|||||||
public Uni<?> getClubArray(@QueryParam("club") long club) {
|
public Uni<?> getClubArray(@QueryParam("club") long club) {
|
||||||
if (club == 0)
|
if (club == 0)
|
||||||
return Uni.createFrom().item("");
|
return Uni.createFrom().item("");
|
||||||
return resultService.getClubArray2(id, club, null);
|
return resultService.getClubArrayPublic(id, club);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import fr.titionfire.ffsaf.domain.service.PDFService;
|
|||||||
import fr.titionfire.ffsaf.rest.data.MeData;
|
import fr.titionfire.ffsaf.rest.data.MeData;
|
||||||
import fr.titionfire.ffsaf.rest.data.SimpleMembre;
|
import fr.titionfire.ffsaf.rest.data.SimpleMembre;
|
||||||
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
import fr.titionfire.ffsaf.rest.exception.DForbiddenException;
|
||||||
import fr.titionfire.ffsaf.rest.from.UserSettingForm;
|
|
||||||
import fr.titionfire.ffsaf.utils.SecurityCtx;
|
import fr.titionfire.ffsaf.utils.SecurityCtx;
|
||||||
import fr.titionfire.ffsaf.utils.Utils;
|
import fr.titionfire.ffsaf.utils.Utils;
|
||||||
import io.quarkus.security.Authenticated;
|
import io.quarkus.security.Authenticated;
|
||||||
@ -114,21 +113,6 @@ public class MembreEndpoints {
|
|||||||
return pdfService.getLicencePdf(securityCtx.getSubject());
|
return pdfService.getLicencePdf(securityCtx.getSubject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("me/setting")
|
|
||||||
@Authenticated
|
|
||||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
|
||||||
@Produces(MediaType.TEXT_PLAIN)
|
|
||||||
@Operation(summary = "Met à jour les paramètres du membre connecté", description = "Met à jour les paramètres du membre connecté")
|
|
||||||
@APIResponses(value = {
|
|
||||||
@APIResponse(responseCode = "200", description = "Les paramètres ont été mis à jour"),
|
|
||||||
@APIResponse(responseCode = "403", description = "Accès refusé"),
|
|
||||||
@APIResponse(responseCode = "500", description = "Erreur interne du serveur")
|
|
||||||
})
|
|
||||||
public Uni<Void> updateMeSettings(UserSettingForm settingForm) {
|
|
||||||
return membreService.updateSettings(securityCtx.getSubject(), settingForm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("me/photo")
|
@Path("me/photo")
|
||||||
@Authenticated
|
@Authenticated
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package fr.titionfire.ffsaf.rest;
|
|||||||
|
|
||||||
import fr.titionfire.ffsaf.domain.service.ResultService;
|
import fr.titionfire.ffsaf.domain.service.ResultService;
|
||||||
import fr.titionfire.ffsaf.rest.data.ResultCategoryData;
|
import fr.titionfire.ffsaf.rest.data.ResultCategoryData;
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
import fr.titionfire.ffsaf.utils.SecurityCtx;
|
import fr.titionfire.ffsaf.utils.SecurityCtx;
|
||||||
import io.quarkus.security.Authenticated;
|
import io.quarkus.security.Authenticated;
|
||||||
import io.smallrye.mutiny.Uni;
|
import io.smallrye.mutiny.Uni;
|
||||||
@ -11,7 +10,6 @@ import jakarta.ws.rs.GET;
|
|||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Authenticated
|
@Authenticated
|
||||||
@ -31,39 +29,15 @@ public class ResultEndpoints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{uuid}/category/list")
|
@Path("{uuid}")
|
||||||
public Uni<HashMap<String, Long>> getCategoryList(@PathParam("uuid") String uuid) {
|
public Uni<List<ResultCategoryData>> getCategory(@PathParam("uuid") String uuid) {
|
||||||
return resultService.getCategoryList(uuid);
|
return resultService.getCategory(uuid, securityCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{uuid}/category/{id}")
|
@Path("{uuid}/club")
|
||||||
public Uni<ResultCategoryData> getCategory(@PathParam("uuid") String uuid, @PathParam("id") long id) {
|
public Uni<ResultService.ClubArrayData> getClub(@PathParam("uuid") String uuid) {
|
||||||
return resultService.getCategory(uuid, id, securityCtx);
|
return resultService.getClubArray(uuid, securityCtx);
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{uuid}/club/list")
|
|
||||||
public Uni<HashMap<String, Long>> getClubList(@PathParam("uuid") String uuid) {
|
|
||||||
return resultService.getClubList(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{uuid}/club/{id}")
|
|
||||||
public Uni<ResultService.ClubArrayData> getClub(@PathParam("uuid") String uuid, @PathParam("id") long id) {
|
|
||||||
return resultService.getClubArray(uuid, id, securityCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{uuid}/comb/list")
|
|
||||||
public Uni<HashMap<String, String>> getCombList(@PathParam("uuid") String uuid) {
|
|
||||||
return resultService.getCombList(uuid, ResultPrivacy.REGISTERED_ONLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{uuid}/comb/{id}")
|
|
||||||
public Uni<?> getCombList(@PathParam("uuid") String uuid, @PathParam("id") String id) {
|
|
||||||
return resultService.getCombArrayPublic(uuid, id, ResultPrivacy.REGISTERED_ONLY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package fr.titionfire.ffsaf.rest.data;
|
package fr.titionfire.ffsaf.rest.data;
|
||||||
|
|
||||||
import fr.titionfire.ffsaf.data.model.MembreModel;
|
import fr.titionfire.ffsaf.data.model.MembreModel;
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -16,32 +15,30 @@ import java.util.List;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
public class MeData {
|
public class MeData {
|
||||||
@Schema(description = "L'identifiant du membre.", examples = "1")
|
@Schema(description = "L'identifiant du membre.", example = "1")
|
||||||
private long id;
|
private long id;
|
||||||
@Schema(description = "Le nom du membre.", examples = "Dupont")
|
@Schema(description = "Le nom du membre.", example = "Dupont")
|
||||||
private String lname = "";
|
private String lname = "";
|
||||||
@Schema(description = "Le prénom du membre.", examples = "Jean")
|
@Schema(description = "Le prénom du membre.", example = "Jean")
|
||||||
private String fname = "";
|
private String fname = "";
|
||||||
@Schema(description = "La catégorie du membre.", examples = "SENIOR")
|
@Schema(description = "La catégorie du membre.", example = "SENIOR")
|
||||||
private String categorie;
|
private String categorie;
|
||||||
@Schema(description = "Le nom du club du membre.", examples = "Association sportive")
|
@Schema(description = "Le nom du club du membre.", example = "Association sportive")
|
||||||
private String club;
|
private String club;
|
||||||
@Schema(description = "Le genre du membre.", examples = "Homme")
|
@Schema(description = "Le genre du membre.", example = "Homme")
|
||||||
private String genre;
|
private String genre;
|
||||||
@Schema(description = "Le numéro de licence du membre.", examples = "12345")
|
@Schema(description = "Le numéro de licence du membre.", example = "12345")
|
||||||
private int licence;
|
private int licence;
|
||||||
@Schema(description = "Le pays du membre.", examples = "FR")
|
@Schema(description = "Le pays du membre.", example = "FR")
|
||||||
private String country;
|
private String country;
|
||||||
@Schema(description = "La date de naissance du membre.")
|
@Schema(description = "La date de naissance du membre.")
|
||||||
private Date birth_date;
|
private Date birth_date;
|
||||||
@Schema(description = "L'adresse e-mail du membre.", examples = "jean.dupont@examples.com")
|
@Schema(description = "L'adresse e-mail du membre.", example = "jean.dupont@example.com")
|
||||||
private String email;
|
private String email;
|
||||||
@Schema(description = "Le rôle du membre dans l'association.", examples = "MEMBRE")
|
@Schema(description = "Le rôle du membre dans l'association.", example = "MEMBRE")
|
||||||
private String role;
|
private String role;
|
||||||
@Schema(description = "Le grade d'arbitrage du membre.", examples = "N/A")
|
@Schema(description = "Le grade d'arbitrage du membre.", example = "N/A")
|
||||||
private String grade_arbitrage;
|
private String grade_arbitrage;
|
||||||
@Schema(description = "La confidentialité des résultats", examples = "PUBLIC")
|
|
||||||
private ResultPrivacy resultPrivacy;
|
|
||||||
@Schema(description = "La liste des licences du membre.")
|
@Schema(description = "La liste des licences du membre.")
|
||||||
private List<SimpleLicence> licences;
|
private List<SimpleLicence> licences;
|
||||||
|
|
||||||
@ -58,6 +55,5 @@ public class MeData {
|
|||||||
this.email = membreModel.getEmail();
|
this.email = membreModel.getEmail();
|
||||||
this.role = membreModel.getRole().str;
|
this.role = membreModel.getRole().str;
|
||||||
this.grade_arbitrage = membreModel.getGrade_arbitrage().str;
|
this.grade_arbitrage = membreModel.getGrade_arbitrage().str;
|
||||||
this.resultPrivacy = membreModel.getResultPrivacy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
package fr.titionfire.ffsaf.rest.data;
|
package fr.titionfire.ffsaf.rest.data;
|
||||||
|
|
||||||
import fr.titionfire.ffsaf.data.model.MatchModel;
|
import fr.titionfire.ffsaf.data.model.MatchModel;
|
||||||
import fr.titionfire.ffsaf.data.model.MembreModel;
|
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
import fr.titionfire.ffsaf.utils.ScoreEmbeddable;
|
||||||
import fr.titionfire.ffsaf.utils.TreeNode;
|
import fr.titionfire.ffsaf.utils.TreeNode;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
@ -40,15 +38,15 @@ public class ResultCategoryData {
|
|||||||
|
|
||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
public record PouleArrayData(String red, boolean red_w, List<Integer[]> score, boolean blue_w, String blue, boolean end) {
|
public record PouleArrayData(String red, boolean red_w, List<Integer[]> score, boolean blue_w, String blue, boolean end) {
|
||||||
public static PouleArrayData fromModel(MatchModel matchModel, MembreModel membreModel, ResultPrivacy privacy) {
|
public static PouleArrayData fromModel(MatchModel matchModel) {
|
||||||
return new PouleArrayData(
|
return new PouleArrayData(
|
||||||
matchModel.getC1Name(membreModel, privacy),
|
matchModel.getC1Name(),
|
||||||
matchModel.isEnd() && matchModel.win() > 0,
|
matchModel.isEnd() && matchModel.win() > 0,
|
||||||
matchModel.isEnd() ?
|
matchModel.isEnd() ?
|
||||||
matchModel.getScores().stream().map(s -> new Integer[]{s.getS1(), s.getS2()}).toList()
|
matchModel.getScores().stream().map(s -> new Integer[]{s.getS1(), s.getS2()}).toList()
|
||||||
: new ArrayList<>(),
|
: new ArrayList<>(),
|
||||||
matchModel.isEnd() && matchModel.win() < 0,
|
matchModel.isEnd() && matchModel.win() < 0,
|
||||||
matchModel.getC2Name(membreModel, privacy),
|
matchModel.getC2Name(),
|
||||||
matchModel.isEnd());
|
matchModel.isEnd());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,8 +54,8 @@ public class ResultCategoryData {
|
|||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
public static record TreeData(long id, String c1FullName, String c2FullName, List<ScoreEmbeddable> scores,
|
public static record TreeData(long id, String c1FullName, String c2FullName, List<ScoreEmbeddable> scores,
|
||||||
boolean end) {
|
boolean end) {
|
||||||
public static TreeData from(MatchModel match, MembreModel membreModel, ResultPrivacy privacy) {
|
public static TreeData from(MatchModel match) {
|
||||||
return new TreeData(match.getId(), match.getC1Name(membreModel, privacy), match.getC2Name(membreModel, privacy), match.getScores(), match.isEnd());
|
return new TreeData(match.getId(), match.getC1Name(), match.getC2Name(), match.getScores(), match.isEnd());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,32 +19,34 @@ import java.util.Date;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
public class SimpleMembre {
|
public class SimpleMembre {
|
||||||
@Schema(description = "L'identifiant du membre.", examples = "1")
|
@Schema(description = "L'identifiant du membre.", example = "1")
|
||||||
private long id;
|
private long id;
|
||||||
@Schema(description = "L'identifiant long du membre (userID).", examples = "e81d1d35-d897-421e-8086-6c5e74d13c6e")
|
@Schema(description = "L'identifiant long du membre (userID).", example = "e81d1d35-d897-421e-8086-6c5e74d13c6e")
|
||||||
private String userId;
|
private String userId;
|
||||||
@Schema(description = "Le nom du membre.", examples = "Dupont")
|
@Schema(description = "Le nom du membre.", example = "Dupont")
|
||||||
private String lname = "";
|
private String lname = "";
|
||||||
@Schema(description = "Le prénom du membre.", examples = "Jean")
|
@Schema(description = "Le prénom du membre.", example = "Jean")
|
||||||
private String fname = "";
|
private String fname = "";
|
||||||
@Schema(description = "La catégorie du membre.", examples = "SENIOR")
|
@Schema(description = "La catégorie du membre.", example = "SENIOR")
|
||||||
private Categorie categorie;
|
private Categorie categorie;
|
||||||
@Schema(description = "Le club du membre.")
|
@Schema(description = "Le club du membre.")
|
||||||
private SimpleClubModel club;
|
private SimpleClubModel club;
|
||||||
@Schema(description = "Le genre du membre.", examples = "H")
|
@Schema(description = "Le genre du membre.", example = "H")
|
||||||
private Genre genre;
|
private Genre genre;
|
||||||
@Schema(description = "Le numéro de licence du membre.", examples = "12345")
|
@Schema(description = "Le numéro de licence du membre.", example = "12345")
|
||||||
private Integer licence;
|
private Integer licence;
|
||||||
@Schema(description = "Le pays du membre.", examples = "FR")
|
@Schema(description = "Le pays du membre.", example = "FR")
|
||||||
private String country;
|
private String country;
|
||||||
@Schema(description = "La date de naissance du membre.")
|
@Schema(description = "La date de naissance du membre.")
|
||||||
private Date birth_date;
|
private Date birth_date;
|
||||||
@Schema(description = "L'adresse e-mail du membre.", examples = "jean.dupont@examples.com")
|
@Schema(description = "L'adresse e-mail du membre.", example = "jean.dupont@example.com")
|
||||||
private String email;
|
private String email;
|
||||||
@Schema(description = "Le rôle du membre dans l'association.", examples = "MEMBRE")
|
@Schema(description = "Le rôle du membre dans l'association.", example = "MEMBRE")
|
||||||
private RoleAsso role;
|
private RoleAsso role;
|
||||||
@Schema(description = "Le grade d'arbitrage du membre.", examples = "N/A")
|
@Schema(description = "Le grade d'arbitrage du membre.", example = "N/A")
|
||||||
private GradeArbitrage grade_arbitrage;
|
private GradeArbitrage grade_arbitrage;
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private String url_photo;
|
||||||
|
|
||||||
public static SimpleMembre fromModel(MembreModel model) {
|
public static SimpleMembre fromModel(MembreModel model) {
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -64,6 +66,7 @@ public class SimpleMembre {
|
|||||||
.email(model.getEmail())
|
.email(model.getEmail())
|
||||||
.role(model.getRole())
|
.role(model.getRole())
|
||||||
.grade_arbitrage(model.getGrade_arbitrage())
|
.grade_arbitrage(model.getGrade_arbitrage())
|
||||||
|
.url_photo(model.getUrl_photo())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
package fr.titionfire.ffsaf.rest.from;
|
|
||||||
|
|
||||||
import fr.titionfire.ffsaf.utils.ResultPrivacy;
|
|
||||||
import jakarta.ws.rs.FormParam;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
|
||||||
|
|
||||||
@ToString
|
|
||||||
@Getter
|
|
||||||
public class UserSettingForm {
|
|
||||||
@FormParam("resultPrivacy")
|
|
||||||
@Schema(description = "La confidentialité des résultats", examples = "PUBLIC", defaultValue = "PUBLIC", required = true)
|
|
||||||
private ResultPrivacy resultPrivacy;
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
package fr.titionfire.ffsaf.utils;
|
|
||||||
|
|
||||||
public enum ResultPrivacy {
|
|
||||||
PUBLIC,
|
|
||||||
REGISTERED_ONLY,
|
|
||||||
REGISTERED_ONLY_NO_DETAILS,
|
|
||||||
PRIVATE;
|
|
||||||
}
|
|
||||||
@ -44,9 +44,9 @@ function AffiliationMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CompMenu() {
|
function CompMenu() {
|
||||||
const {is_authenticated} = useAuth()
|
const {is_authenticated, userinfo} = useAuth()
|
||||||
|
|
||||||
if (!is_authenticated)
|
if (!is_authenticated || !userinfo?.roles?.includes("federation_admin"))
|
||||||
return <></>
|
return <></>
|
||||||
|
|
||||||
return <li className="nav-item dropdown">
|
return <li className="nav-item dropdown">
|
||||||
|
|||||||
@ -12,10 +12,6 @@ import {
|
|||||||
faUserGroup,
|
faUserGroup,
|
||||||
faVenus
|
faVenus
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import {CheckField} from "../components/MemberCustomFiels.jsx";
|
|
||||||
import {toast} from "react-toastify";
|
|
||||||
import {apiAxios} from "../utils/Tools.js";
|
|
||||||
import {useEffect, useState} from "react";
|
|
||||||
|
|
||||||
const vite_url = import.meta.env.VITE_URL;
|
const vite_url = import.meta.env.VITE_URL;
|
||||||
|
|
||||||
@ -34,7 +30,6 @@ export function MePage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="col-lg-8">
|
<div className="col-lg-8">
|
||||||
<InformationForm data={data}/>
|
<InformationForm data={data}/>
|
||||||
<SettingsCard data={data}/>
|
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
<LoadingProvider><LicenceCard userData={data}/></LoadingProvider>
|
<LoadingProvider><LicenceCard userData={data}/></LoadingProvider>
|
||||||
@ -101,47 +96,8 @@ function SelectCard() {
|
|||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SettingsCard({data}) {
|
|
||||||
const [privacy, setPrivacy] = useState("PUBLIC");
|
|
||||||
|
|
||||||
useEffect(() => {
|
export function InformationForm({data}) {
|
||||||
if (data?.resultPrivacy) {
|
|
||||||
setPrivacy(data.resultPrivacy);
|
|
||||||
}
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
const handleChange = (e) => {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("resultPrivacy", e.target.value);
|
|
||||||
toast.promise(apiAxios.put(`/member/me/setting`, formData),
|
|
||||||
{
|
|
||||||
pending: 'Mise à jours des paramètres en cours...',
|
|
||||||
success: 'Paramètres mis à jours avec succès 🎉',
|
|
||||||
error: 'Échec de la mise à jours des paramètres 😕'
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
setPrivacy(String(formData.get("resultPrivacy")));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return <div className="card mb-4">
|
|
||||||
<div className="card-header">Paramètres du compte</div>
|
|
||||||
<div className="card-body">
|
|
||||||
<div className="input-group mb-3">
|
|
||||||
<label className="input-group-text" htmlFor="email_notifications">Visibilité des résultats</label>
|
|
||||||
<select className="form-select" id="result_visibility" name="result_visibility" required value={privacy} onChange={handleChange}>
|
|
||||||
<option value="PUBLIC">Public (visible par tous)</option>
|
|
||||||
<option value="REGISTERED_ONLY">Membres connectés (visibles par les membres de la fédération)</option>
|
|
||||||
<option value="REGISTERED_ONLY_NO_DETAILS">Membres connectés - masquer les détails (visibles par les membres de la fédération)
|
|
||||||
</option>
|
|
||||||
<option value="PRIVATE">Privé (visible uniquement par moi)</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>;
|
|
||||||
}
|
|
||||||
|
|
||||||
function InformationForm({data}) {
|
|
||||||
const style = {marginRight: '0.7em'}
|
const style = {marginRight: '0.7em'}
|
||||||
|
|
||||||
return <div className="card mb-4">
|
return <div className="card mb-4">
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import {useLoadingSwitcher} from "../../hooks/useLoading.jsx";
|
|||||||
import {useFetch} from "../../hooks/useFetch.js";
|
import {useFetch} from "../../hooks/useFetch.js";
|
||||||
import {AxiosError} from "../../components/AxiosError.jsx";
|
import {AxiosError} from "../../components/AxiosError.jsx";
|
||||||
import {ThreeDots} from "react-loader-spinner";
|
import {ThreeDots} from "react-loader-spinner";
|
||||||
import React, {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {DrawGraph} from "./DrawGraph.jsx";
|
import {DrawGraph} from "./DrawGraph.jsx";
|
||||||
import {TreeNode} from "../../utils/TreeUtils.js";
|
import {TreeNode} from "../../utils/TreeUtils.js";
|
||||||
import {scoreToString} from "../../utils/CompetitionTools.js";
|
import {scoreToString} from "../../utils/CompetitionTools.js";
|
||||||
@ -17,45 +17,50 @@ function CupImg() {
|
|||||||
export function ResultView() {
|
export function ResultView() {
|
||||||
const {uuid} = useParams()
|
const {uuid} = useParams()
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [resultShow, setResultShow] = useState("cat")
|
const [resultShow, setResultShow] = useState(null)
|
||||||
|
|
||||||
|
const setLoading = useLoadingSwitcher()
|
||||||
|
const {data, error} = useFetch(`/result/${uuid}`, setLoading, 1)
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<button type="button" className="btn btn-link" onClick={() => navigate("/result")}>
|
<button type="button" className="btn btn-link" onClick={() => navigate("/result")}>
|
||||||
« retour
|
« retour
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<MenuBar resultShow={resultShow} setResultShow={setResultShow}/>
|
{data ? <MenuBar data={data} resultShow={resultShow} setResultShow={setResultShow}/>
|
||||||
|
: error
|
||||||
|
? <AxiosError error={error}/>
|
||||||
|
: <Def/>}
|
||||||
|
|
||||||
<div className="row" style={{marginTop: "1em"}}>
|
<div className="row">
|
||||||
<div className="col-auto">
|
<div className="col-auto">
|
||||||
{resultShow && resultShow === "cat" && <CategoryList uuid={uuid}/>
|
{resultShow && resultShow.type !== undefined && <PouleResult data={resultShow}/>
|
||||||
|| resultShow && resultShow === "club" && <ClubList uuid={uuid}/>
|
|| resultShow && resultShow === "club" && <ClubResult uuid={uuid}/>
|
||||||
|| resultShow && resultShow === "comb" && <CombList uuid={uuid}/>
|
|| resultShow && resultShow === "comb" && <CombResult uuid={uuid}/>}
|
||||||
|| resultShow && resultShow === "combs" && <CombsResult uuid={uuid}/>}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
// || resultShow && resultShow === "club_all" && <ClubAllResult uuid={uuid}/>
|
// || resultShow && resultShow === "club_all" && <ClubAllResult uuid={uuid}/>
|
||||||
|
|
||||||
function MenuBar({resultShow, setResultShow}) {
|
function MenuBar({data, resultShow, setResultShow}) {
|
||||||
return <ul className="nav nav-tabs">
|
return <ul className="nav nav-tabs">
|
||||||
<li className="nav-item">
|
<li className="nav-item dropdown">
|
||||||
<a className={"nav-link my-1" + (resultShow === "cat" ? " active" : "")} aria-current={(resultShow === "cat" ? " page" : "false")}
|
<a className={"nav-link dropdown-toggle my-1"} data-bs-toggle="dropdown" href="#"
|
||||||
href="#" onClick={_ => setResultShow("cat")}>Par catégorie</a>
|
aria-current={(resultShow?.type !== undefined ? " page" : "false")} role="button" aria-expanded="false">Catégorie</a>
|
||||||
|
<ul className="dropdown-menu">
|
||||||
|
{data.map(item => <li><a key={item.name} className={"dropdown-item" + (resultShow === item ? " active" : "")}
|
||||||
|
aria-current={(resultShow === item ? " page" : "false")} href="#" data-bs-toggle="collapse"
|
||||||
|
onClick={_ => setResultShow(item)}>{item.name}</a></li>)}
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li className="nav-item">
|
<li className="nav-item">
|
||||||
<a className={"nav-link my-1" + (resultShow === "club" ? " active" : "")} aria-current={(resultShow === "club" ? " page" : "false")}
|
<a className={"nav-link my-1" + (resultShow === "club" ? " active" : "")} aria-current={(resultShow === "club" ? " page" : "false")}
|
||||||
href="#" onClick={_ => setResultShow("club")}>Par club</a>
|
href="#" onClick={_ => setResultShow("club")}>Mon club</a>
|
||||||
</li>
|
</li>
|
||||||
<li className="nav-item">
|
<li className="nav-item">
|
||||||
<a className={"nav-link my-1" + (resultShow === "comb" ? " active" : "")} aria-current={(resultShow === "comb" ? " page" : "false")}
|
<a className={"nav-link my-1" + (resultShow === "comb" ? " active" : "")} aria-current={(resultShow === "comb" ? " page" : "false")}
|
||||||
href="#" onClick={_ => setResultShow("comb")}>Par combattant</a>
|
href="#" onClick={_ => setResultShow("comb")}>Combattants</a>
|
||||||
</li>
|
|
||||||
<li className="nav-item">
|
|
||||||
<a className={"nav-link my-1" + (resultShow === "combs" ? " active" : "")} aria-current={(resultShow === "combs" ? " page" : "false")}
|
|
||||||
href="#" onClick={_ => setResultShow("combs")}>Combattants</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -143,51 +148,13 @@ function BuildTree({treeData}) {
|
|||||||
return <DrawGraph root={initTree(treeData)}/>
|
return <DrawGraph root={initTree(treeData)}/>
|
||||||
}
|
}
|
||||||
|
|
||||||
function CategoryList({uuid}) {
|
function PouleResult({data}) {
|
||||||
const [catId, setCatId] = useState(null)
|
const [type, setType] = useState(data.type === 3 ? 1 : data.type)
|
||||||
const setLoading = useLoadingSwitcher()
|
|
||||||
const {data, error} = useFetch(`/result/${uuid}/category/list`, setLoading, 1)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data && Object.keys(data).length > 0)
|
setType(data.type === 3 ? 1 : data.type)
|
||||||
setCatId(data[Object.keys(data).sort()[0]])
|
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
return <>
|
|
||||||
{data ? <div className="input-group" style={{marginBottom: "1em"}}>
|
|
||||||
<h6 style={{margin: "auto 0.5em auto 0"}}>Catégorie</h6>
|
|
||||||
<select className="form-select" aria-label="Select Result Type" onChange={e => setCatId(e.target.value)}>
|
|
||||||
{Object.keys(data).sort().map(key => <option key={key} value={data[key]}>{key}</option>)}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
: error
|
|
||||||
? <AxiosError error={error}/>
|
|
||||||
: <Def/>}
|
|
||||||
{catId && <CategoryResult uuid={uuid} catId={catId}/>}
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
|
|
||||||
function CategoryResult({uuid, catId}) {
|
|
||||||
const [type, setType] = useState(1)
|
|
||||||
|
|
||||||
const setLoading = useLoadingSwitcher()
|
|
||||||
const {data, refresh, error} = useFetch(`/result/${uuid}/category/${catId}`, setLoading, 1)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
refresh(`/result/${uuid}/category/${catId}`)
|
|
||||||
}, [catId]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (data)
|
|
||||||
setType(data.type === 3 ? 1 : data.type)
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
return error
|
|
||||||
? <AxiosError error={error}/>
|
|
||||||
: <Def/>
|
|
||||||
}
|
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
{data.type === 3 && <>
|
{data.type === 3 && <>
|
||||||
<ul className="nav nav-tabs">
|
<ul className="nav nav-tabs">
|
||||||
@ -217,37 +184,9 @@ function CategoryResult({uuid, catId}) {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
function ClubList({uuid}) {
|
function ClubResult({uuid}) {
|
||||||
const [clubId, setClubId] = useState(null)
|
|
||||||
const setLoading = useLoadingSwitcher()
|
const setLoading = useLoadingSwitcher()
|
||||||
const {data, error} = useFetch(`/result/${uuid}/club/list`, setLoading, 1)
|
const {data, error} = useFetch(`/result/${uuid}/club`, setLoading, 1)
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (data && Object.keys(data).length > 0)
|
|
||||||
setClubId(data[Object.keys(data).sort()[0]])
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
return <>
|
|
||||||
{data ? <div className="input-group" style={{marginBottom: "1em"}}>
|
|
||||||
<h6 style={{margin: "auto 0.5em auto 0"}}>Club</h6>
|
|
||||||
<select className="form-select" aria-label="Select Result Type" onChange={e => setClubId(e.target.value)}>
|
|
||||||
{Object.keys(data).sort().map(key => <option key={key} value={data[key]}>{key}</option>)}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
: error
|
|
||||||
? <AxiosError error={error}/>
|
|
||||||
: <Def/>}
|
|
||||||
{clubId && <ClubResult uuid={uuid} clubId={clubId}/>}
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
|
|
||||||
function ClubResult({uuid, clubId}) {
|
|
||||||
const setLoading = useLoadingSwitcher()
|
|
||||||
const {data, refresh, error} = useFetch(`/result/${uuid}/club/${clubId}`, setLoading, 1)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
refresh(`/result/${uuid}/club/${clubId}`)
|
|
||||||
}, [clubId]);
|
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
{data ? <>
|
{data ? <>
|
||||||
@ -303,102 +242,25 @@ function ClubResult({uuid, clubId}) {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
function CombList({uuid}) {
|
/*function ClubAllResult({uuid}) {
|
||||||
const [combId, setCombId] = useState(null)
|
return <div></div>
|
||||||
const setLoading = useLoadingSwitcher()
|
|
||||||
const {data, error} = useFetch(`/result/${uuid}/comb/list`, setLoading, 1)
|
|
||||||
|
|
||||||
useEffect(() => {
|
}*/
|
||||||
if (data && Object.keys(data).length > 0)
|
|
||||||
setCombId(data[Object.keys(data).sort()[0]])
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
return <>
|
function CombResult({uuid}) {
|
||||||
{data ? <div className="input-group" style={{marginBottom: "1em"}}>
|
|
||||||
<h6 style={{margin: "auto 0.5em auto 0"}}>Combattant</h6>
|
|
||||||
<select className="form-select" aria-label="Select Result Type" onChange={e => setCombId(e.target.value)}>
|
|
||||||
{Object.keys(data).sort().map(key => <option key={key} value={data[key]}>{key}</option>)}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
: error
|
|
||||||
? <AxiosError error={error}/>
|
|
||||||
: <Def/>}
|
|
||||||
{combId && <CombResult uuid={uuid} combId={combId}/>}
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
|
|
||||||
function CombResult({uuid, combId}) {
|
|
||||||
const setLoading = useLoadingSwitcher()
|
|
||||||
const {data, refresh, error} = useFetch(`/result/${uuid}/comb/${combId}`, setLoading, 1)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
refresh(`/result/${uuid}/comb/${combId}`)
|
|
||||||
}, [combId]);
|
|
||||||
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
return error
|
|
||||||
? <AxiosError error={error}/>
|
|
||||||
: <Def/>
|
|
||||||
}
|
|
||||||
|
|
||||||
return <div>
|
|
||||||
<h3>Info :</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Nom Prénom : {data.name}</li>
|
|
||||||
<li>Club : {data.club}</li>
|
|
||||||
<li>Catégorie : {data.cat}</li>
|
|
||||||
</ul>
|
|
||||||
<h3>Statistique :</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Taux de victoire : {data.matchs.length === 0 ? "---" : (data.totalWin / data.matchs.length * 100).toFixed(0)}% ({data.totalWin} sur
|
|
||||||
${data.matchs.length})
|
|
||||||
</li>
|
|
||||||
<li>Points marqués : {data.pointMake}</li>
|
|
||||||
<li>Points reçus : {data.pointTake}</li>
|
|
||||||
<li>Ratio du score (point marqué / point reçu): {data.pointRatio.toFixed(3)}</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Liste des matchs:</h3>
|
|
||||||
|
|
||||||
<table className="table table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" style={{textAlign: "center"}}>Catégorie</th>
|
|
||||||
<th scope="col" style={{textAlign: "center"}}>Adversaire</th>
|
|
||||||
<th scope="col" style={{textAlign: "center"}}>Scores</th>
|
|
||||||
<th scope="col" style={{textAlign: "center"}}>Ratio</th>
|
|
||||||
<th scope="col" style={{textAlign: "center"}}></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
{data.matchs.map((match, idx) => <tr key={idx}>
|
|
||||||
<td style={{textAlign: "center"}}>{match.poule}</td>
|
|
||||||
<td style={{textAlign: "center"}}>{match.adv}</td>
|
|
||||||
<td style={{textAlign: "center"}}>{scoreToString(match.score)}</td>
|
|
||||||
<td style={{textAlign: "center"}}>{match.ratio.toFixed(3)}</td>
|
|
||||||
<td style={{textAlign: "left"}}>{match.win ? <CupImg/> : ""}</td>
|
|
||||||
</tr>)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
function CombsResult({uuid}) {
|
|
||||||
const setLoading = useLoadingSwitcher()
|
const setLoading = useLoadingSwitcher()
|
||||||
const {data, error} = useFetch(`/result/${uuid}/comb`, setLoading, 1)
|
const {data, error} = useFetch(`/result/${uuid}/comb`, setLoading, 1)
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
{data ? <>
|
{data ? <>
|
||||||
<h3>Statistique :</h3>
|
<h3>Statistique :</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Nombre d'inscris : {data.nb_insc}</li>
|
<li>Nombre d'inscris : {data.nb_insc}</li>
|
||||||
<li>Nombre de match disputé : {data.tt_match}</li>
|
<li>Nombre de match disputé : {data.tt_match}</li>
|
||||||
<li>Points marqués : {data.point}</li>
|
<li>Points marqués : {data.point}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Liste des combattants :</h3>
|
<h3>Liste des combattants :</h3>
|
||||||
|
|
||||||
<table className="table table-striped">
|
<table className="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user