refactor(tournament): improve top 3 participant identification in PDF generation
- Updated the logic in the TournamentPlacementsTab component to filter and identify top 3 participants from K.O. rounds more accurately. - Replaced the previous method of using final placements with a check for filtered K.O. rounds, enhancing the reliability of the data used in PDF generation. - Ensured that the PDF generation process correctly handles cases where no K.O. rounds are present, maintaining clarity in the output.
This commit is contained in:
@@ -541,28 +541,30 @@ export default {
|
||||
async generateMissingDataPDF() {
|
||||
this.pdfLoading = true;
|
||||
try {
|
||||
// 1. Top-3-Platzierte ermitteln (aus K.O.-Runden und Gruppen)
|
||||
// 1. Top-3-Platzierte ermitteln
|
||||
const top3Names = new Set();
|
||||
const top3Ids = new Set();
|
||||
|
||||
// Aus K.O.-Endplatzierungen (finalPlacementsByClass)
|
||||
for (const [, placements] of Object.entries(this.finalPlacementsByClass)) {
|
||||
for (const entry of placements) {
|
||||
if (Number(entry.position) > 3) continue;
|
||||
if (entry.displayName) {
|
||||
// Doppel: beide Namen extrahieren
|
||||
entry.displayName.split('/').forEach(n => top3Names.add(n.trim()));
|
||||
} else if (entry.member) {
|
||||
const fn = (entry.member.firstName || '').trim();
|
||||
const ln = (entry.member.lastName || '').trim();
|
||||
if (fn || ln) top3Names.add(`${fn} ${ln}`.trim());
|
||||
if (entry.member.id != null) top3Ids.add(Number(entry.member.id));
|
||||
// Aus K.O.-Endplatzierungen (nur gefilterte = echte K.O.-Runden)
|
||||
const hasKORound = Object.keys(this.finalPlacementsByClassFiltered).length > 0;
|
||||
if (hasKORound) {
|
||||
for (const [, placements] of Object.entries(this.finalPlacementsByClassFiltered)) {
|
||||
for (const entry of placements) {
|
||||
if (Number(entry.position) > 3) continue;
|
||||
if (entry.displayName) {
|
||||
entry.displayName.split('/').forEach(n => top3Names.add(n.trim()));
|
||||
} else if (entry.member) {
|
||||
const fn = (entry.member.firstName || '').trim();
|
||||
const ln = (entry.member.lastName || '').trim();
|
||||
if (fn || ln) top3Names.add(`${fn} ${ln}`.trim());
|
||||
if (entry.member.id != null) top3Ids.add(Number(entry.member.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Aus Gruppen-Platzierungen (wenn keine K.O.-Runde vorhanden)
|
||||
if (top3Names.size === 0) {
|
||||
if (!hasKORound) {
|
||||
for (const gp of this.groupPlacements) {
|
||||
for (const r of (gp.rankings || [])) {
|
||||
if (Number(r.position) > 3) continue;
|
||||
|
||||
Reference in New Issue
Block a user