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
All checks were successful
Deploy to production / deploy (push) Successful in 1m59s
This commit is contained in:
@@ -697,24 +697,35 @@ export default {
|
||||
return [{ ...item, learning, reference }];
|
||||
},
|
||||
normalizePool(items = []) {
|
||||
const seen = new Set();
|
||||
return (Array.isArray(items) ? items : [])
|
||||
.flatMap((item, index) => this.expandPoolItemAlternatives(item).map((candidate, altIndex) => ({ candidate, index, altIndex })))
|
||||
.map(({ candidate, index, altIndex }) => {
|
||||
const learning = String(candidate?.learning || '').trim();
|
||||
const reference = String(candidate?.reference || '').trim();
|
||||
if (!this.isTrainablePair(learning, reference)) return null;
|
||||
const key = `${this.normalize(learning)}|${this.normalize(reference)}`;
|
||||
if (seen.has(key)) return null;
|
||||
seen.add(key);
|
||||
return {
|
||||
...candidate,
|
||||
id: candidate?.id || candidate?.itemKey || candidate?.key || `${key}|${index}|${altIndex}`,
|
||||
learning,
|
||||
reference
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
try {
|
||||
const inputLen = Array.isArray(items) ? items.length : 0;
|
||||
const seen = new Set();
|
||||
const expanded = (Array.isArray(items) ? items : [])
|
||||
.flatMap((item, index) => this.expandPoolItemAlternatives(item).map((candidate, altIndex) => ({ candidate, index, altIndex })));
|
||||
|
||||
const mapped = expanded
|
||||
.map(({ candidate, index, altIndex }) => {
|
||||
const learning = String(candidate?.learning || '').trim();
|
||||
const reference = String(candidate?.reference || '').trim();
|
||||
if (!this.isTrainablePair(learning, reference)) return null;
|
||||
const key = `${this.normalize(learning)}|${this.normalize(reference)}`;
|
||||
if (seen.has(key)) return null;
|
||||
seen.add(key);
|
||||
return {
|
||||
...candidate,
|
||||
id: candidate?.id || candidate?.itemKey || candidate?.key || `${key}|${index}|${altIndex}`,
|
||||
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() {
|
||||
this.current = null;
|
||||
|
||||
Reference in New Issue
Block a user