Aktualisiere die Version auf 1.8.10 und füge Vereinsrang (QTTR / TTR) zur QTTR-Tabelle hinzu. Implementiere die Logik zur Berechnung und Sortierung der Vereinsränge in den API- und Import-Skripten.
This commit is contained in:
@@ -37,6 +37,26 @@ function buildBirthdateLookup(entries) {
|
||||
return lookup
|
||||
}
|
||||
|
||||
function addClubRanks(rows) {
|
||||
const addRankFor = (valueKey, rankKey) => {
|
||||
rows
|
||||
.filter((row) => row[valueKey] != null)
|
||||
.sort((a, b) => b[valueKey] - a[valueKey] || String(a.playerName || '').localeCompare(String(b.playerName || ''), 'de'))
|
||||
.forEach((row, index) => {
|
||||
row[rankKey] = index + 1
|
||||
})
|
||||
}
|
||||
|
||||
addRankFor('currentQttr', 'clubQttrRank')
|
||||
addRankFor('currentTtr', 'clubTtrRank')
|
||||
|
||||
return rows.sort((a, b) =>
|
||||
(a.clubQttrRank ?? Number.POSITIVE_INFINITY) - (b.clubQttrRank ?? Number.POSITIVE_INFINITY)
|
||||
|| (a.clubTtrRank ?? Number.POSITIVE_INFINITY) - (b.clubTtrRank ?? Number.POSITIVE_INFINITY)
|
||||
|| String(a.playerName || '').localeCompare(String(b.playerName || ''), 'de')
|
||||
)
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const token = getCookie(event, 'auth_token') || getHeader(event, 'authorization')?.replace(/^Bearer\s+/i, '')
|
||||
if (!token || !verifyToken(token)) {
|
||||
@@ -73,16 +93,16 @@ export default defineEventHandler(async (event) => {
|
||||
].flatMap(entry => [entry?.name, `${entry?.firstName || ''} ${entry?.lastName || ''}`.trim()]).map(normalizeName).filter(Boolean))
|
||||
const birthdateLookup = buildBirthdateLookup([...visibleManualMembers, ...visibleUsers])
|
||||
|
||||
const rankedRows = addClubRanks(Array.isArray(payload.rows) ? payload.rows.map(row => ({ ...row })) : [])
|
||||
|
||||
return {
|
||||
...payload,
|
||||
rows: Array.isArray(payload.rows)
|
||||
? payload.rows
|
||||
rows: rankedRows
|
||||
.filter(row => !hiddenNames.has(normalizeName(row.playerName)))
|
||||
.map((row) => ({
|
||||
...row,
|
||||
birthdate: birthdateLookup.get(normalizeName(row.playerName)) || row.birthdate || ''
|
||||
}))
|
||||
: []
|
||||
}
|
||||
} catch (error) {
|
||||
if (error?.code === 'ENOENT') {
|
||||
@@ -98,4 +118,4 @@ export default defineEventHandler(async (event) => {
|
||||
message: 'Fehler beim Laden der QTTR-Werte.'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user