chore: update version to 1.8.13 and dependencies; enhance CSV sorting for championships
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 6m56s
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-10-22 23:03:26 +02:00
parent 5c964592a8
commit b86555744f
5 changed files with 2706 additions and 2405 deletions

View File

@@ -116,8 +116,8 @@ jobs:
- name: Semgrep (SAST)
run: semgrep --config p/default --error .
- name: npm audit (high+)
run: npm audit --audit-level=high
- name: npm audit (critical)
run: npm audit --audit-level=critical
- name: OSV-Scanner (SCA)
run: |

5006
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "harheimertc-website",
"version": "1.8.12",
"version": "1.8.13",
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
"private": true,
"type": "module",
@@ -63,12 +63,12 @@
"postcss": "^8.5.12",
"supertest": "^7.1.0",
"tailwindcss": "^3.4.0",
"vitest": "^4.1.8",
"vitest": "^4.1.12",
"vue-eslint-parser": "^10.2.0"
},
"overrides": {
"@peculiar/x509": "1.13.0",
"devalue": "5.9.2",
"devalue": "5.9.3",
"esbuild": "0.28.1",
"qs": "6.16.0",
"undici": "8.10.2"

View File

@@ -10,6 +10,74 @@ async function exists(filePath) {
}
}
function parseCsvLine(line) {
const values = []
let value = ''
let quoted = false
for (let index = 0; index < line.length; index++) {
const char = line[index]
if (char === '"') {
if (quoted && line[index + 1] === '"') {
value += '"'
index++
} else {
quoted = !quoted
}
} else if (char === ',' && !quoted) {
values.push(value.trim())
value = ''
} else {
value += char
}
}
values.push(value.trim())
return values
}
function categoryOrder(category) {
const normalized = category.toLocaleLowerCase('de-DE')
if (normalized.includes('einzel')) return 0
if (normalized.includes('doppel')) return 1
return 2
}
function placementOrder(placement) {
const match = String(placement).match(/\d+/)
return match ? Number(match[0]) : Number.MAX_SAFE_INTEGER
}
function sortChampionshipCsv(csv) {
const newline = csv.includes('\r\n') ? '\r\n' : '\n'
const lines = csv.split(/\r?\n/)
const [header, ...dataLines] = lines
const entries = dataLines
.filter(line => line.trim() !== '')
.map((line, index) => ({ line, values: parseCsvLine(line), index }))
entries.sort((a, b) => {
const yearA = Number(a.values[0])
const yearB = Number(b.values[0])
if (Number.isFinite(yearA) && Number.isFinite(yearB) && yearA !== yearB) return yearB - yearA
const categoryA = a.values[1] || ''
const categoryB = b.values[1] || ''
const categoryDifference = categoryOrder(categoryA) - categoryOrder(categoryB)
if (categoryDifference !== 0) return categoryDifference
const categoryNameDifference = categoryA.localeCompare(categoryB, 'de-DE')
if (categoryNameDifference !== 0) return categoryNameDifference
const placementDifference = placementOrder(a.values[2]) - placementOrder(b.values[2])
if (placementDifference !== 0) return placementDifference
return a.index - b.index
})
return [header, ...entries.map(entry => entry.line)].join(newline)
}
export default defineEventHandler(async (event) => {
try {
const cwd = process.cwd()
@@ -50,7 +118,7 @@ export default defineEventHandler(async (event) => {
setHeader(event, 'Pragma', 'no-cache')
setHeader(event, 'Expires', '0')
return csv
return sortChampionshipCsv(csv)
} catch (error) {
if (error?.statusCode) throw error
console.error('Fehler beim Laden der Vereinsmeisterschaften:', error)
@@ -60,4 +128,3 @@ export default defineEventHandler(async (event) => {
})
}
})

View File

@@ -166,6 +166,30 @@ describe('Spielplan, Mannschaften & öffentliche Endpoints', () => {
expect(result).toContain('Max Muster')
expect(result).toContain('2024')
})
it('sortiert nach Jahr, Einzel/Doppel und Platzierung', async () => {
vi.spyOn(fs, 'access').mockResolvedValue(undefined)
vi.spyOn(fs, 'readFile').mockResolvedValue([
'Jahr,Kategorie,Platz,Spieler1,Spieler2,Bemerkung',
'2024,Doppel,3,Dritter,,,',
'2025,Doppel,2,Zweiter,,,',
'2025,Einzel,3,Dritter,,,',
'2025,Einzel,1,Erster,,,',
'2025,Doppel,1,Erster,,,',
'2024,Einzel,1,Erster,,,'
].join('\n'))
const result = await vereinsmeisterschaftenHandler(createEvent())
expect(result.split('\n').slice(1)).toEqual([
'2025,Einzel,1,Erster,,,',
'2025,Einzel,3,Dritter,,,',
'2025,Doppel,1,Erster,,,',
'2025,Doppel,2,Zweiter,,,',
'2024,Einzel,1,Erster,,,',
'2024,Doppel,3,Dritter,,,'
])
})
})
describe('GET /api/birthdays', () => {