feat(match-report): improve test validation messages and add original report comparison logic
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 55s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 55s
This commit is contained in:
@@ -88,7 +88,7 @@
|
||||
|
||||
<div v-if="isTestMode && testSubmissionResult" class="test-submit-result"
|
||||
:class="testSubmissionResult.valid ? 'test-success' : 'test-error'">
|
||||
<strong>{{ testSubmissionResult.valid ? '✓ Testprüfung erfolgreich' : '⚠ Testprüfung fehlgeschlagen' }}</strong>
|
||||
<strong>{{ testSubmissionResult.valid ? '✓ Testdaten entsprechen dem NuScore-Original' : '⚠ Testdaten weichen vom NuScore-Original ab' }}</strong>
|
||||
<p>{{ testSubmissionResult.summary }}</p>
|
||||
<ul v-if="testSubmissionResult.messages.length">
|
||||
<li v-for="message in testSubmissionResult.messages" :key="message">{{ message }}</li>
|
||||
@@ -1922,33 +1922,72 @@ Wir wünschen den Spielen einen schönen, spannenden und fairen Verlauf und begr
|
||||
},
|
||||
|
||||
runTestValidation() {
|
||||
const messages = [];
|
||||
const validationMessages = [];
|
||||
const teamNotAppeared = this.teamNotAppeared !== null;
|
||||
|
||||
if (!teamNotAppeared) {
|
||||
if (!this.areAllMatchResultsValid()) {
|
||||
messages.push('Die Ergebniserfassung enthält unvollständige oder ungültige Spiele.');
|
||||
validationMessages.push('Die Ergebniserfassung enthält unvollständige oder ungültige Spiele.');
|
||||
}
|
||||
if (!this.areStartAndEndTimesValid()) {
|
||||
messages.push('Start- und Endzeit müssen beide gesetzt sein.');
|
||||
validationMessages.push('Start- und Endzeit müssen beide gesetzt sein.');
|
||||
}
|
||||
if (!this.isHomeLineupCertified) {
|
||||
messages.push('Die Heimaufstellung wurde noch nicht bestätigt.');
|
||||
validationMessages.push('Die Heimaufstellung wurde noch nicht bestätigt.');
|
||||
}
|
||||
if (!this.isGuestLineupCertified) {
|
||||
messages.push('Die Gastaufstellung wurde noch nicht bestätigt.');
|
||||
validationMessages.push('Die Gastaufstellung wurde noch nicht bestätigt.');
|
||||
}
|
||||
}
|
||||
|
||||
const originalComparison = this.compareTestResultsToOriginal();
|
||||
const messages = [...validationMessages, ...originalComparison.messages];
|
||||
|
||||
this.testSubmissionResult = {
|
||||
valid: messages.length === 0,
|
||||
summary: messages.length === 0
|
||||
? 'Der lokale Testbericht erfüllt alle Prüfregeln. Es wurden keine Daten an NuScore übermittelt.'
|
||||
: 'Der lokale Testbericht kann in diesem Zustand nicht abgeschlossen werden. Es wurden keine Daten an NuScore übermittelt.',
|
||||
valid: validationMessages.length === 0 && originalComparison.matches,
|
||||
summary: validationMessages.length === 0 && originalComparison.matches
|
||||
? 'Die lokale Testübermittlung enthält dieselben Paarungen und Ergebnisse wie der gespeicherte NuScore-Originaldatensatz. Es wurden keine Daten an NuScore übermittelt.'
|
||||
: 'Die lokale Testübermittlung unterscheidet sich noch vom gespeicherten NuScore-Originaldatensatz. Es wurden keine Daten an NuScore übermittelt.',
|
||||
messages
|
||||
};
|
||||
},
|
||||
|
||||
compareTestResultsToOriginal() {
|
||||
const originalRows = this.getOriginalReportRows();
|
||||
if (!originalRows.length) {
|
||||
return { matches: false, messages: ['Für den Vergleich sind keine Original-Ergebnisse vorhanden.'] };
|
||||
}
|
||||
|
||||
const normalizeName = (value) => String(value || '').replace(/\s+/g, ' ').trim().toLocaleLowerCase('de-DE');
|
||||
const normalizeSets = (sets) => (Array.isArray(sets) ? sets : []).map(set => String(set || '').trim());
|
||||
const messages = [];
|
||||
|
||||
originalRows.forEach((original, index) => {
|
||||
const local = this.results[index];
|
||||
if (!local) {
|
||||
messages.push(`Spiel ${original.matchNumber}: fehlt im Testbericht.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (normalizeName(local.homeName) !== normalizeName(original.homeName) ||
|
||||
normalizeName(local.guestName) !== normalizeName(original.guestName)) {
|
||||
messages.push(`Spiel ${original.matchNumber}: Paarung weicht ab.`);
|
||||
}
|
||||
|
||||
const originalSets = normalizeSets(original.sets);
|
||||
const localSets = normalizeSets(local.sets);
|
||||
if (originalSets.length !== localSets.length || originalSets.some((set, setIndex) => set !== localSets[setIndex])) {
|
||||
messages.push(`Spiel ${original.matchNumber}: Satzergebnisse weichen ab (Original: ${original.setsText || '–'}).`);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.results.length !== originalRows.length) {
|
||||
messages.push(`Die Anzahl der Spiele weicht ab (Test: ${this.results.length}, Original: ${originalRows.length}).`);
|
||||
}
|
||||
|
||||
return { matches: messages.length === 0, messages };
|
||||
},
|
||||
|
||||
async submitMatchReport() {
|
||||
try {
|
||||
console.log('🚀 Starte Spielbericht-Absendung...');
|
||||
|
||||
Reference in New Issue
Block a user