diff --git a/server/parser/untis.js b/server/parser/untis.js index bc3fbef..851cf45 100644 --- a/server/parser/untis.js +++ b/server/parser/untis.js @@ -58,8 +58,18 @@ export function parseSubstitutionPlan(html) { rowData[columntitle] = cleantext; }); + // Split change if it spans over multiple lessons const rawLesson = rowData.lesson; - const lessons = rawLesson.match(/\d+/g).map(Number); + const fromToLessons = rawLesson.match(/\d+/g).map(Number); + const from = fromToLessons[0]; + const to = fromToLessons[1] || fromToLessons[0]; + + // Generate numbers from `from` to `to` + const lessons = Array(to - from + 1) + .fill() + .map((_e, i) => i + from); + + // Create new change for each lesson the change spans over for (const lesson of lessons) { rowData.lesson = lesson; data.push({ ...rowData });