feat(TournamentStats): update internal tournament scoring logic and UI enhancements
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 36s

- Revised scoring system for internal tournaments to assign points based on placement (1st = 100, 2nd = 99, etc.), with adjustments for tied ranks and a cap at 101 points.
- Refactored `groupPointsFromRankings` function for improved clarity and efficiency.
- Enhanced the InternalTournamentStats component UI, integrating a dialog for better user interaction and accessibility.
- Updated localization strings across multiple languages to reflect the new scoring system and UI changes, improving user understanding and experience.
This commit is contained in:
Torsten Schulz (local)
2026-04-08 11:02:34 +02:00
parent 4a53801a54
commit 43dbd5442a
18 changed files with 170 additions and 109 deletions

View File

@@ -1,7 +1,8 @@
/**
* Statistik-Punkte für interne Einzel-Turniere (Gruppenphase + K.-o.-Runde).
*
* Gruppe: Letzter in der Gruppe = 1 Punkt, Vorletzter = 2, … Gleiche Platzierung = gleiche Punkte.
* Gruppe: 1. Platz = 100, 2. = 99, 3. = 98, … (Platzierung aus API: 1 = bestes Ergebnis).
* Gleiche Platzierung = gleiche Punkte. Ab Platz 101 wird mit 0 gekappt.
* K.-o.: Wer die K.-o.-Runde erreicht: höchste Gruppenpunkte dieser Klasse + 1,
* danach +1 pro gewonnenes K.-o.-Spiel.
*/
@@ -50,24 +51,18 @@ export function parseWinnerFromMatch(match) {
/**
* @param {Array<{ position: number, id: number }>} rankings Platz 1 = bestes Ergebnis; id = Turnier-Mitglied-ID
* @returns {Map<number, number>} tournamentMemberId -> Punkte (von unten gezählt)
* @returns {Map<number, number>} tournamentMemberId -> Punkte (1. Platz 100, 2. 99, …)
*/
export function groupPointsFromRankings(rankings) {
const map = new Map();
if (!rankings || rankings.length === 0) return map;
const sorted = [...rankings].sort((a, b) => Number(b.position) - Number(a.position));
let pts = 1;
let i = 0;
while (i < sorted.length) {
const pos = Number(sorted[i].position);
let j = i;
while (j < sorted.length && Number(sorted[j].position) === pos) {
const id = sorted[j].id;
if (id != null) map.set(Number(id), pts);
j += 1;
}
i = j;
pts += 1;
for (const r of rankings) {
const pos = Number(r.position);
if (!Number.isFinite(pos) || pos < 1) continue;
const id = r.id;
if (id == null) continue;
const pts = Math.max(0, 101 - pos);
map.set(Number(id), pts);
}
return map;
}