Merge pull request 'feat: add match eq support' (#102) from dev into master
Reviewed-on: #102
This commit is contained in:
commit
a942798a6c
@ -174,46 +174,25 @@ public class ResultService {
|
||||
.distinct()
|
||||
.filter(Objects::nonNull)
|
||||
.map(comb -> {
|
||||
AtomicInteger w = new AtomicInteger(0);
|
||||
AtomicInteger pointMake = new AtomicInteger(0);
|
||||
AtomicInteger pointTake = new AtomicInteger(0);
|
||||
|
||||
matchEntities.stream()
|
||||
.filter(m -> m.isEnd() && (m.isC1(comb) || m.isC2(comb)))
|
||||
.forEach(matchModel -> {
|
||||
int win = matchModel.win();
|
||||
if ((matchModel.isC1(comb) && win > 0) || matchModel.isC2(comb) && win < 0)
|
||||
w.getAndIncrement();
|
||||
|
||||
for (ScoreEmbeddable score : matchModel.getScores()) {
|
||||
if (score.getS1() <= -900 || score.getS2() <= -900)
|
||||
continue;
|
||||
if (matchModel.isC1(comb)) {
|
||||
pointMake.addAndGet(score.getS1());
|
||||
pointTake.addAndGet(score.getS2());
|
||||
} else {
|
||||
pointMake.addAndGet(score.getS2());
|
||||
pointTake.addAndGet(score.getS1());
|
||||
}
|
||||
}
|
||||
});
|
||||
float pointRate = (pointTake.get() == 0) ? pointMake.get() : (float) pointMake.get() / pointTake.get();
|
||||
|
||||
CombStat stat = makeStat(matchEntities, comb);
|
||||
return new ResultCategoryData.RankArray(0,
|
||||
comb.getName(membreModel, ResultPrivacy.REGISTERED_ONLY_NO_DETAILS), w.get(),
|
||||
pointMake.get(), pointTake.get(), pointRate);
|
||||
comb.getName(membreModel, ResultPrivacy.REGISTERED_ONLY_NO_DETAILS), stat.score, stat.w,
|
||||
stat.pointMake, stat.pointTake, stat.getPointRate());
|
||||
})
|
||||
.sorted(Comparator
|
||||
.comparing(ResultCategoryData.RankArray::getWin)
|
||||
.comparing(ResultCategoryData.RankArray::getScore)
|
||||
.thenComparing(ResultCategoryData.RankArray::getWin)
|
||||
.thenComparing(ResultCategoryData.RankArray::getPointRate).reversed())
|
||||
.toList();
|
||||
out.getMatchs().put(c, matchs);
|
||||
|
||||
int lastScore = -1;
|
||||
int lastWin = -1;
|
||||
float pointRate = 0;
|
||||
int rank = 0;
|
||||
for (ResultCategoryData.RankArray rankArray1 : rankArray) {
|
||||
if (rankArray1.getWin() != lastWin || pointRate != rankArray1.getPointRate()) {
|
||||
if (rankArray1.getScore() != lastScore || rankArray1.getWin() != lastWin || pointRate != rankArray1.getPointRate()) {
|
||||
lastScore = rankArray1.getScore();
|
||||
lastWin = rankArray1.getWin();
|
||||
pointRate = rankArray1.getPointRate();
|
||||
rank++;
|
||||
@ -275,12 +254,7 @@ public class ResultService {
|
||||
.distinct()
|
||||
.map(comb -> {
|
||||
var builder2 = CombsArrayData.CombsData.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);
|
||||
CombStat stat = makeStat(matchModels, comb);
|
||||
|
||||
Categorie categorie = null;
|
||||
String clubName = null;
|
||||
@ -302,14 +276,13 @@ public class ResultService {
|
||||
|
||||
builder2.cat((categorie == null) ? "---" : categorie.getName(trad));
|
||||
builder2.name(comb.getName(membreModel, ResultPrivacy.REGISTERED_ONLY));
|
||||
builder2.w(w.get());
|
||||
builder2.l(l.get());
|
||||
builder2.ratioVictoire((l.get() == 0) ? w.get() : (float) w.get() / l.get());
|
||||
builder2.w(stat.w);
|
||||
builder2.l(stat.l);
|
||||
builder2.ratioVictoire((stat.l == 0) ? stat.w : (float) stat.w / stat.l);
|
||||
builder2.club(clubName);
|
||||
builder2.pointMake(pointMake.get());
|
||||
builder2.pointTake(pointTake.get());
|
||||
builder2.ratioPoint(
|
||||
(pointTake.get() == 0) ? pointMake.get() : (float) pointMake.get() / pointTake.get());
|
||||
builder2.pointMake(stat.pointMake);
|
||||
builder2.pointTake(stat.pointTake);
|
||||
builder2.ratioPoint(stat.getPointRate());
|
||||
|
||||
return builder2.build();
|
||||
})
|
||||
@ -434,7 +407,7 @@ public class ResultService {
|
||||
} else {
|
||||
builder2.score(new ArrayList<>());
|
||||
}
|
||||
builder2.win(matchModel.win() > 0);
|
||||
builder2.win(matchModel.isEnd() && matchModel.win() > 0);
|
||||
} else {
|
||||
builder2.adv(Utils.getFullName(matchModel.getC1_id(), matchModel.getC1_guest()));
|
||||
if (matchModel.isEnd()) {
|
||||
@ -449,9 +422,9 @@ public class ResultService {
|
||||
} else {
|
||||
builder2.score(new ArrayList<>());
|
||||
}
|
||||
builder2.win(matchModel.win() < 0);
|
||||
builder2.win(matchModel.isEnd() && matchModel.win() < 0);
|
||||
}
|
||||
|
||||
builder2.eq(matchModel.isEnd() && matchModel.win() == 0);
|
||||
builder2.ratio(
|
||||
(pointTake.get() == 0) ? pointMake.get() : (float) pointMake.get() / pointTake.get());
|
||||
|
||||
@ -495,7 +468,7 @@ public class ResultService {
|
||||
@Builder
|
||||
@RegisterForReflection
|
||||
public static record MatchsData(Date date, String poule, String adv, List<Integer[]> score, float ratio,
|
||||
boolean win) {
|
||||
boolean win, boolean eq) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,12 +539,7 @@ public class ResultService {
|
||||
|
||||
List<ClubArrayData.CombData> combData = combs.stream().map(comb -> {
|
||||
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);
|
||||
CombStat stat = makeStat(matchModels, comb);
|
||||
|
||||
Categorie categorie = null;
|
||||
|
||||
@ -587,15 +555,15 @@ public class ResultService {
|
||||
|
||||
builder2.cat((categorie == null) ? "---" : categorie.getName(trad));
|
||||
builder2.name(comb.getName(membreModel, ResultPrivacy.REGISTERED_ONLY));
|
||||
builder2.w(w.get());
|
||||
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());
|
||||
builder2.w(stat.w);
|
||||
builder2.l(stat.l);
|
||||
builder2.ratioVictoire((stat.l == 0) ? stat.w : (float) stat.w / stat.l);
|
||||
builder2.pointMake(stat.pointMake);
|
||||
builder2.pointTake(stat.pointTake);
|
||||
builder2.ratioPoint(stat.getPointRate());
|
||||
|
||||
tt_win.addAndGet(w.get());
|
||||
tt_match.addAndGet(w.get() + l.get());
|
||||
tt_win.addAndGet(stat.w);
|
||||
tt_match.addAndGet(stat.w + stat.l);
|
||||
|
||||
return builder2.build();
|
||||
})
|
||||
@ -615,30 +583,34 @@ public class ResultService {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static void makeStat(List<MatchModel> matchModels, CombModel comb, AtomicInteger w, AtomicInteger l,
|
||||
AtomicInteger pointMake, AtomicInteger pointTake) {
|
||||
private static CombStat makeStat(List<MatchModel> matchModels, CombModel comb) {
|
||||
CombStat stat = new CombStat();
|
||||
matchModels.stream()
|
||||
.filter(m -> m.isEnd() && (m.isC1(comb) || m.isC2(comb)))
|
||||
.forEach(matchModel -> {
|
||||
int win = matchModel.win();
|
||||
if ((matchModel.isC1(comb) && win > 0) || matchModel.isC2(comb) && win < 0) {
|
||||
w.getAndIncrement();
|
||||
if (win == 0) {
|
||||
stat.score += 1;
|
||||
} else if ((matchModel.isC1(comb) && win > 0) || matchModel.isC2(comb) && win < 0) {
|
||||
stat.w++;
|
||||
stat.score += 3;
|
||||
} else {
|
||||
l.getAndIncrement();
|
||||
stat.l++;
|
||||
}
|
||||
|
||||
matchModel.getScores().stream()
|
||||
.filter(s -> s.getS1() > -900 && s.getS2() > -900)
|
||||
.forEach(score -> {
|
||||
if (matchModel.isC1(comb)) {
|
||||
pointMake.addAndGet(score.getS1());
|
||||
pointTake.addAndGet(score.getS2());
|
||||
stat.pointMake += score.getS1();
|
||||
stat.pointTake += score.getS2();
|
||||
} else {
|
||||
pointMake.addAndGet(score.getS2());
|
||||
pointTake.addAndGet(score.getS1());
|
||||
stat.pointMake += score.getS2();
|
||||
stat.pointTake += score.getS1();
|
||||
}
|
||||
});
|
||||
});
|
||||
return stat;
|
||||
}
|
||||
|
||||
@Builder
|
||||
@ -652,6 +624,27 @@ public class ResultService {
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public static class CombStat {
|
||||
public int w;
|
||||
public int l;
|
||||
public int score;
|
||||
public int pointMake;
|
||||
public int pointTake;
|
||||
|
||||
public CombStat() {
|
||||
this.w = 0;
|
||||
this.l = 0;
|
||||
this.score = 0;
|
||||
this.pointMake = 0;
|
||||
this.pointTake = 0;
|
||||
}
|
||||
|
||||
public float getPointRate() {
|
||||
return (pointTake == 0) ? pointMake : (float) pointMake / pointTake;
|
||||
}
|
||||
}
|
||||
|
||||
private Uni<MembreModel> hasAccess(String uuid, SecurityCtx securityCtx) {
|
||||
return registerRepository.find("membre.userId = ?1 AND competition.uuid = ?2", securityCtx.getSubject(), uuid)
|
||||
.firstResult()
|
||||
@ -678,7 +671,8 @@ public class ResultService {
|
||||
securityCtx.getSubject())
|
||||
.chain(c2 -> {
|
||||
if (c2 > 0) return Uni.createFrom().item(m);
|
||||
return Uni.createFrom().failure(new DForbiddenException(trad.t("access.denied")));
|
||||
return Uni.createFrom()
|
||||
.failure(new DForbiddenException(trad.t("access.denied")));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -11,6 +11,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@ -32,6 +33,7 @@ public class ResultCategoryData {
|
||||
public static class RankArray {
|
||||
int rank;
|
||||
String name;
|
||||
int score;
|
||||
int win;
|
||||
int pointMake;
|
||||
int pointTake;
|
||||
@ -39,7 +41,8 @@ public class ResultCategoryData {
|
||||
}
|
||||
|
||||
@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 eq, boolean end, Date date) {
|
||||
public static PouleArrayData fromModel(MatchModel matchModel, MembreModel membreModel, ResultPrivacy privacy) {
|
||||
return new PouleArrayData(
|
||||
matchModel.getC1Name(membreModel, privacy),
|
||||
@ -49,7 +52,9 @@ public class ResultCategoryData {
|
||||
: new ArrayList<>(),
|
||||
matchModel.isEnd() && matchModel.win() < 0,
|
||||
matchModel.getC2Name(membreModel, privacy),
|
||||
matchModel.isEnd());
|
||||
matchModel.isEnd() && matchModel.win() == 0,
|
||||
matchModel.isEnd(),
|
||||
matchModel.getDate());
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +62,8 @@ public class ResultCategoryData {
|
||||
public static record TreeData(long id, String c1FullName, String c2FullName, List<ScoreEmbeddable> scores,
|
||||
boolean end) {
|
||||
public static TreeData from(MatchModel match, MembreModel membreModel, ResultPrivacy privacy) {
|
||||
return new TreeData(match.getId(), match.getC1Name(membreModel, privacy), match.getC2Name(membreModel, privacy), match.getScores(), match.isEnd());
|
||||
return new TreeData(match.getId(), match.getC1Name(membreModel, privacy),
|
||||
match.getC2Name(membreModel, privacy), match.getScores(), match.isEnd());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,9 @@ const rootDiv = document.getElementById("safca_api_data");
|
||||
const cupImg = `<img decoding="async" loading="lazy" width="16" height="16" class="wp-image-1635"
|
||||
style="width: 16px;" src="https://intra.ffsaf.fr/img/171891.png"
|
||||
alt="">`
|
||||
const cupImg2 = `<img decoding="async" loading="lazy" width="16" height="16" class="wp-image-1635"
|
||||
style="width: 16px;" src="https://intra.ffsaf.fr/img/171892.png"
|
||||
alt="">`
|
||||
|
||||
|
||||
const voidFunction = () => {
|
||||
@ -15,7 +18,7 @@ let lastRf = 0;
|
||||
let rfFonction = voidFunction;
|
||||
|
||||
setInterval(() => {
|
||||
rfFonction();
|
||||
// rfFonction();
|
||||
}, 15000);
|
||||
|
||||
function setSubPage(name) {
|
||||
@ -214,11 +217,11 @@ function buildMatchArray(matchs) {
|
||||
arrayContent += `
|
||||
<tr>
|
||||
<td class="has-text-align-right" data-align="right">${match.red}</td>
|
||||
<td class="has-text-align-center" data-align="center">${match.red_w ? cupImg : ""}</td>
|
||||
<td class="has-text-align-center" data-align="center">${match.red_w ? cupImg : (match.eq ? cupImg2 : "")}</td>
|
||||
<td class="has-text-align-center" data-align="center">${scoreToString(match.score)}</td>
|
||||
<td class="has-text-align-center" data-align="center">${match.blue_w ? cupImg : ""}</td>
|
||||
<td class="has-text-align-center" data-align="center">${match.blue_w ? cupImg : (match.eq ? cupImg2 : "")}</td>
|
||||
<td class="has-text-align-left" data-align="left">${match.blue}</td>
|
||||
<td class="has-text-align-center" data-align="center">${dateToString((match.red_w || match.blue_w) ? match.date : null)}</td>
|
||||
<td class="has-text-align-center" data-align="center">${dateToString((match.end) ? match.date : null)}</td>
|
||||
</tr>`
|
||||
}
|
||||
arrayContent += `</tbody></table></figure>`
|
||||
@ -234,6 +237,7 @@ function buildRankArray(rankArray) {
|
||||
<tr>
|
||||
<th class="has-text-align-center" data-align="center">${i18next.t('place')}</th>
|
||||
<th class="has-text-align-center" data-align="center">${i18next.t('nom')}</th>
|
||||
<th class="has-text-align-center" data-align="center">${i18next.t('score')}</th>
|
||||
<th class="has-text-align-center" data-align="center">${i18next.t('victoire')}</th>
|
||||
<th class="has-text-align-center" data-align="center">${i18next.t('ratio')}</th>
|
||||
<th class="has-text-align-center" data-align="center">${i18next.t('pointsMarqués')}</th>
|
||||
@ -245,6 +249,7 @@ function buildRankArray(rankArray) {
|
||||
<tr>
|
||||
<td class="has-text-align-center" data-align="center">${row.rank}</td>
|
||||
<td class="has-text-align-left" data-align="left">${row.name}</td>
|
||||
<td class="has-text-align-center" data-align="center">${row.score}</td>
|
||||
<td class="has-text-align-center" data-align="center">${row.win}</td>
|
||||
<td class="has-text-align-center" data-align="center">${row.pointRate.toFixed(3)}</td>
|
||||
<td class="has-text-align-center" data-align="center">${row.pointMake}</td>
|
||||
@ -419,7 +424,7 @@ function buildCombView(comb) {
|
||||
<td class="has-text-align-center" data-align="center">${match.adv}</td>
|
||||
<td class="has-text-align-center" data-align="center">${scoreToString(match.score)}</td>
|
||||
<td class="has-text-align-center" data-align="center">${match.ratio.toFixed(3)}</td>
|
||||
<td class="has-text-align-center" data-align="center">${match.win ? cupImg : ""}</td>
|
||||
<td class="has-text-align-center" data-align="center">${match.win ? cupImg : (match.eq ? cupImg2 : "")}</td>
|
||||
</tr>`
|
||||
}
|
||||
arrayContent += `</tbody></table></figure>`
|
||||
|
||||
BIN
src/main/webapp/public/img/171892.png
Normal file
BIN
src/main/webapp/public/img/171892.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@ -57,6 +57,7 @@
|
||||
"rechercheParCombattant": "Search by fighter",
|
||||
"rouge": "Red",
|
||||
"résultatDeLaCompétition": "Competition result",
|
||||
"score": "Score",
|
||||
"scores": "Scores",
|
||||
"statistique": "Statistics",
|
||||
"tauxDeVictoire2": "Win rate: {{nb}}% ({{victoires}} out of {{matchs}})",
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
"rechercheParCombattant": "Recherche par combattant",
|
||||
"rouge": "Rouge",
|
||||
"résultatDeLaCompétition": "Résultat de la compétition",
|
||||
"score": "Score",
|
||||
"scores": "Scores",
|
||||
"statistique": "Statistique",
|
||||
"tauxDeVictoire2": "Taux de victoire : {{nb}}% ({{victoires}} sur {{matchs}})",
|
||||
|
||||
@ -14,6 +14,11 @@ function CupImg() {
|
||||
style={{width: "16px"}} src="/img/171891.png"
|
||||
alt=""/>
|
||||
}
|
||||
function CupImg2() {
|
||||
return <img decoding="async" loading="lazy" width="16" height="16" className="wp-image-1635"
|
||||
style={{width: "16px"}} src="/img/171892.png"
|
||||
alt=""/>
|
||||
}
|
||||
|
||||
export function ResultView() {
|
||||
const {uuid} = useParams()
|
||||
@ -87,9 +92,9 @@ function BuildMatchArray({matchs}) {
|
||||
<tbody>
|
||||
{matchs.map((match, idx) => <tr key={idx}>
|
||||
<td style={{textAlign: "right"}}>{match.red}</td>
|
||||
<td style={{textAlign: "center"}}>{match.red_w ? <CupImg/> : ""}</td>
|
||||
<td style={{textAlign: "center"}}>{match.red_w ? <CupImg/> : (match.eq ? <CupImg2/> : "")}</td>
|
||||
<td style={{textAlign: "center"}}>{scoreToString(match.score)}</td>
|
||||
<td style={{textAlign: "center"}}>{match.blue_w ? <CupImg/> : ""}</td>
|
||||
<td style={{textAlign: "center"}}>{match.blue_w ? <CupImg/> : (match.eq ? <CupImg2/> : "")}</td>
|
||||
<td style={{textAlign: "left"}}>{match.blue}</td>
|
||||
</tr>)}
|
||||
</tbody>
|
||||
@ -105,6 +110,7 @@ function BuildRankArray({rankArray}) {
|
||||
<tr>
|
||||
<th scope="col" style={{textAlign: "center"}}>{t('place')}</th>
|
||||
<th scope="col" style={{textAlign: "center"}}>{t('nom')}</th>
|
||||
<th scope="col" style={{textAlign: "center"}}>{t('score')}</th>
|
||||
<th scope="col" style={{textAlign: "center"}}>{t('victoire')}</th>
|
||||
<th scope="col" style={{textAlign: "center"}}>{t('ratio')}</th>
|
||||
<th scope="col" style={{textAlign: "center"}}>{t('pointsMarqués')}</th>
|
||||
@ -115,6 +121,7 @@ function BuildRankArray({rankArray}) {
|
||||
{rankArray.map((row, idx) => <tr key={idx}>
|
||||
<td style={{textAlign: "center"}}>{row.rank}</td>
|
||||
<td style={{textAlign: "left"}}>{row.name}</td>
|
||||
<td style={{textAlign: "center"}}>{row.score}</td>
|
||||
<td style={{textAlign: "center"}}>{row.win}</td>
|
||||
<td style={{textAlign: "center"}}>{row.pointRate.toFixed(3)}</td>
|
||||
<td style={{textAlign: "center"}}>{row.pointMake}</td>
|
||||
@ -395,7 +402,7 @@ function CombResult({uuid, combId}) {
|
||||
<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>
|
||||
<td style={{textAlign: "left"}}>{match.win ? <CupImg/> : (match.eq ? <CupImg2/> : "")}</td>
|
||||
</tr>)}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user