Verbessere TTR-Wert-Import: Füge parallele Abrufe für aktuelle und frühere Ranglisten hinzu und verbessere die Zuordnung von QTTR-Daten.
All checks were successful
Code Analysis and Production Deploy / analyze (push) Successful in 4m27s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 2m38s

This commit is contained in:
Torsten Schulz (local)
2026-09-04 16:39:34 +02:00
parent 3fb60227df
commit 395e2a84bd
2 changed files with 23 additions and 7 deletions

View File

@@ -215,19 +215,29 @@ export async function importQttrValues(options = {}) {
}
async function importAuthenticatedTtrValues(connection) {
const entries = await fetchClubRankings(connection)
const rows = entries.map((entry, index) => ({
const [ttrEntries, qttrEntries] = await Promise.all([
fetchClubRankings(connection, 'yes'),
fetchClubRankings(connection, 'no')
])
const qttrByPlayer = new Map(qttrEntries.map(entry => [
String(entry.personId || `${entry.firstname || ''}|${entry.lastname || ''}`).toLowerCase(), entry
]))
const rows = ttrEntries.map((entry, index) => {
const key = String(entry.personId || `${entry.firstname || ''}|${entry.lastname || ''}`).toLowerCase()
const qttrEntry = qttrByPlayer.get(key)
return ({
rank: toNumberOrNull(entry.rank ?? entry.ranking ?? index + 1),
playerNumber: toNumberOrNull(entry.playernr ?? entry.player_number ?? entry.nuid),
gender: normalizeGender(entry.gender),
playerName: `${entry.firstname ?? entry.first_name ?? ''} ${entry.lastname ?? entry.last_name ?? ''}`.trim() || entry.name || null,
clubName: entry.clubname ?? entry.club_name ?? 'Harheimer TC',
currentQttr: toNumberOrNull(entry.qttr ?? entry.q_ttr ?? entry.ttr),
currentTtr: toNumberOrNull(entry.ttr ?? entry.current_ttr),
currentQttr: toNumberOrNull(qttrEntry?.fedRank ?? qttrEntry?.qttr ?? entry.qttr),
currentTtr: toNumberOrNull(entry.fedRank ?? entry.ttr ?? entry.current_ttr),
previousQttr: null,
valuesByHeader: entry,
rawCells: []
})).filter(row => row.playerName && row.currentQttr != null)
})
}).filter(row => row.playerName && (row.currentTtr != null || row.currentQttr != null))
if (!rows.length) throw new Error('Keine verwertbaren TTR-Werte in der myTischtennis-Rangliste gefunden.')
const importedAt = new Date().toISOString()