From 43dbd5442ab3a3533d3022b0e2a2c0fe15c242bd Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 8 Apr 2026 11:02:34 +0200 Subject: [PATCH] feat(TournamentStats): update internal tournament scoring logic and UI enhancements - 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. --- .../internalTournamentStatsService.js | 25 ++- .../tournament/InternalTournamentStats.vue | 161 ++++++++++-------- frontend/src/i18n/locales/de-CH.json | 3 +- frontend/src/i18n/locales/de-extended.json | 3 +- frontend/src/i18n/locales/de.json | 3 +- frontend/src/i18n/locales/en-AU.json | 3 +- frontend/src/i18n/locales/en-GB.json | 3 +- frontend/src/i18n/locales/en-US.json | 3 +- frontend/src/i18n/locales/es.json | 3 +- frontend/src/i18n/locales/fil.json | 3 +- frontend/src/i18n/locales/fr.json | 3 +- frontend/src/i18n/locales/it.json | 3 +- frontend/src/i18n/locales/ja.json | 3 +- frontend/src/i18n/locales/pl.json | 3 +- frontend/src/i18n/locales/th.json | 3 +- frontend/src/i18n/locales/tl.json | 3 +- frontend/src/i18n/locales/zh.json | 3 +- frontend/src/views/TournamentsView.vue | 48 +++++- 18 files changed, 170 insertions(+), 109 deletions(-) diff --git a/backend/services/internalTournamentStatsService.js b/backend/services/internalTournamentStatsService.js index 8b7a6cb3..860323de 100644 --- a/backend/services/internalTournamentStatsService.js +++ b/backend/services/internalTournamentStatsService.js @@ -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} tournamentMemberId -> Punkte (von unten gezählt) + * @returns {Map} 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; } diff --git a/frontend/src/components/tournament/InternalTournamentStats.vue b/frontend/src/components/tournament/InternalTournamentStats.vue index 89bbae38..2238fe17 100644 --- a/frontend/src/components/tournament/InternalTournamentStats.vue +++ b/frontend/src/components/tournament/InternalTournamentStats.vue @@ -1,74 +1,92 @@