feat: füge sicheres Backup des alten Frontends hinzu und verbessere Fehlerbehandlung in normalizePool
All checks were successful
Deploy to production / deploy (push) Successful in 1m59s

This commit is contained in:
Torsten Schulz (local)
2026-06-04 18:20:07 +02:00
parent 4754ae37da
commit 3176a8b07f
2 changed files with 35 additions and 21 deletions

View File

@@ -57,9 +57,12 @@ echo "✅ Build erfolgreich!"
echo "Erstelle Zielverzeichnis..." echo "Erstelle Zielverzeichnis..."
sudo mkdir -p /opt/yourpart/frontend/dist sudo mkdir -p /opt/yourpart/frontend/dist
# 7. Altes Frontend löschen # 7. Sicheres Backup des alten Frontends (timestamped). Vermeidet Datenverlust bei Fehlern.
echo "Lösche altes Frontend..." if [ -d "/opt/yourpart/frontend/dist" ]; then
sudo rm -rf /opt/yourpart/frontend/dist TIMESTAMP=$(date +%Y%m%d-%H%M%S)
echo "Erstelle Backup von altem Frontend nach /opt/yourpart/frontend/dist.backup.$TIMESTAMP"
sudo mv /opt/yourpart/frontend/dist /opt/yourpart/frontend/dist.backup.$TIMESTAMP || true
fi
# 8. Zielverzeichnis neu erstellen # 8. Zielverzeichnis neu erstellen
echo "Erstelle Zielverzeichnis neu..." echo "Erstelle Zielverzeichnis neu..."

View File

@@ -697,24 +697,35 @@ export default {
return [{ ...item, learning, reference }]; return [{ ...item, learning, reference }];
}, },
normalizePool(items = []) { normalizePool(items = []) {
const seen = new Set(); try {
return (Array.isArray(items) ? items : []) const inputLen = Array.isArray(items) ? items.length : 0;
.flatMap((item, index) => this.expandPoolItemAlternatives(item).map((candidate, altIndex) => ({ candidate, index, altIndex }))) const seen = new Set();
.map(({ candidate, index, altIndex }) => { const expanded = (Array.isArray(items) ? items : [])
const learning = String(candidate?.learning || '').trim(); .flatMap((item, index) => this.expandPoolItemAlternatives(item).map((candidate, altIndex) => ({ candidate, index, altIndex })));
const reference = String(candidate?.reference || '').trim();
if (!this.isTrainablePair(learning, reference)) return null; const mapped = expanded
const key = `${this.normalize(learning)}|${this.normalize(reference)}`; .map(({ candidate, index, altIndex }) => {
if (seen.has(key)) return null; const learning = String(candidate?.learning || '').trim();
seen.add(key); const reference = String(candidate?.reference || '').trim();
return { if (!this.isTrainablePair(learning, reference)) return null;
...candidate, const key = `${this.normalize(learning)}|${this.normalize(reference)}`;
id: candidate?.id || candidate?.itemKey || candidate?.key || `${key}|${index}|${altIndex}`, if (seen.has(key)) return null;
learning, seen.add(key);
reference return {
}; ...candidate,
}) id: candidate?.id || candidate?.itemKey || candidate?.key || `${key}|${index}|${altIndex}`,
.filter(Boolean); learning,
reference
};
});
const result = mapped.filter(Boolean);
try { console.debug('[VocabPracticeDialog] normalizePool', { inputLen, outLen: result.length, sample: result.slice(0,5) }); } catch (_) {}
return result;
} catch (e) {
console.warn('[VocabPracticeDialog] normalizePool failed', e);
return [];
}
}, },
resetQuestion() { resetQuestion() {
this.current = null; this.current = null;