feat: füge Unterstützung für importierte Spielplan-Teams hinzu und verbessere Teamfilter-Logik
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 6m37s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped

This commit is contained in:
Torsten Schulz (local)
2026-07-17 09:29:34 +02:00
parent 30465c7833
commit 1dc84023d0
3 changed files with 100 additions and 39 deletions

View File

@@ -39,6 +39,38 @@ function isErwachsenenTeam(teamKey) {
return teamKey === 'erwachsene' || teamKey.startsWith('erwachsene_')
}
function romanToNumber(value) {
const roman = String(value || '').toUpperCase()
if (!/^[IVX]+$/.test(roman)) return null
const values = { I: 1, V: 5, X: 10 }
let total = 0
for (let index = 0; index < roman.length; index += 1) {
const current = values[roman[index]] || 0
const next = values[roman[index + 1]] || 0
total += current < next ? -current : current
}
return total || null
}
function parseJugendTeamKey(teamKey) {
const match = String(teamKey || '').match(/^jugend_?j?(\d{1,2})(?:_([ivx]+|\d+))?$/i)
if (!match) return null
const teamNumber = match[2]
? (Number(match[2]) || romanToNumber(match[2]))
: null
return { age: match[1], teamNumber: teamNumber ? String(teamNumber) : '' }
}
function sideMatchesJugendTeam({ isHarheimer, ageClass, teamNumber }, team) {
if (!isHarheimer) return false
const agePattern = new RegExp(`(?:jugend\\s*|j)${team.age}\\b`, 'i')
if (!agePattern.test(ageClass)) return false
return !team.teamNumber || String(teamNumber || '').trim() === team.teamNumber
}
export function rowMatchesWettbewerbFilter(row, rawWettbewerb) {
const wettbewerb = normalizeText(rawWettbewerb || 'punktrunde')
const runde = normalizeText(row?.Runde)
@@ -79,6 +111,19 @@ export function rowMatchesTeamFilter(row, rawTeam) {
return isJugendHeim || isJugendGast
}
const jugendTeam = parseJugendTeamKey(teamKey)
if (jugendTeam) {
return sideMatchesJugendTeam({
isHarheimer: isHarheimerHeim,
ageClass: heimAltersklasse,
teamNumber: row?.HeimMannschaftNr
}, jugendTeam) || sideMatchesJugendTeam({
isHarheimer: isHarheimerGast,
ageClass: gastAltersklasse,
teamNumber: row?.GastMannschaftNr
}, jugendTeam)
}
const csvVariants = MANNSCHAFT_MAPPING[teamKey] || []
if (csvVariants.length === 0) {
return false