Verbessere TTR-Wert-Import: Füge parallele Abrufe für aktuelle und frühere Ranglisten hinzu und verbessere die Zuordnung von QTTR-Daten.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user