Add script for importing match schedule and logging
Some checks failed
Code Analysis and Production Deploy / analyze (push) Has been skipped
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 2m2s
Code Analysis and Production Deploy / analyze (pull_request) Failing after 33s
Code Analysis and Production Deploy / deploy-production (pull_request) Has been skipped
Code Analysis and Production Deploy / deploy-test (pull_request) Has been skipped
Require Package Version Change / check (pull_request) Failing after 10s

- Created `import-spielplan.js` to fetch and parse the match schedule from the specified URL, saving the output as JSON.
- Added `run-spielplan-import.sh` to automate the execution of the import script and log output.
- Introduced `spielplan.html` file to store the downloaded HTML content for further processing.
This commit is contained in:
Torsten Schulz (local)
2026-05-19 16:23:28 +02:00
parent c78adc0d52
commit 0849c625cb
21 changed files with 11413 additions and 233 deletions

View File

@@ -397,7 +397,11 @@ const save = async () => {
try {
const csv = [h.join(';'), ...d.map(row => row.join(';'))].join('\n')
const response = await fetch('/api/cms/save-csv', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ filename: 'spielplan.csv', content: csv }) })
if (response.ok) alert('Spielplan erfolgreich gespeichert!'); else alert('Fehler beim Speichern!')
if (response.ok) {
const result = await response.json()
const seasonFile = result.jsonWrittenTo?.[0]?.split('/').pop()
alert(seasonFile ? `Spielplan erfolgreich als ${seasonFile} gespeichert!` : 'Spielplan erfolgreich gespeichert!')
} else alert('Fehler beim Speichern!')
} catch (error) { console.error('Fehler:', error); alert('Fehler beim Speichern!') }
}
@@ -406,11 +410,12 @@ const closeUploadModal = () => { showUploadModal.value = false; selectedFile.val
onMounted(() => {
(async () => {
try {
const response = await fetch('/data/spielplan.csv'); if (!response.ok) return; const text = await response.text()
const lines = text.split('\n').filter(line => line.trim() !== ''); if (lines.length < 2) return
const parseCSVLine = (line) => { const values = []; let current = ''; let inQuotes = false; for (let i = 0; i < line.length; i++) { const char = line[i]; if (char === '"') { inQuotes = !inQuotes } else if (char === ',' && !inQuotes) { values.push(current.trim()); current = '' } else { current += char } }; values.push(current.trim()); return values }
csvHeaders.value = parseCSVLine(lines[0]); csvData.value = lines.slice(1).map(line => parseCSVLine(line))
currentFile.value = { name: 'spielplan.csv', size: text.length, lastModified: null }
const response = await fetch('/api/spielplan'); if (!response.ok) return
const result = await response.json(); if (!result.success || !Array.isArray(result.headers) || !Array.isArray(result.data)) return
csvHeaders.value = result.headers
csvData.value = result.data.map(row => csvHeaders.value.map(header => row[header] || ''))
selectedColumns.value = new Array(csvHeaders.value.length).fill(true)
currentFile.value = { name: result.season ? `spielplan-${result.season}.json` : 'spielplan.csv', size: csvData.value.length, lastModified: null }
} catch { /* ignore */ }
})()
})