From e36c90786ad1b76d3576aa46245ac3f93a2df514 Mon Sep 17 00:00:00 2001 From: minie4 Date: Mon, 2 May 2022 23:44:23 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Split=20substitution=20if=20it=20is?= =?UTF-8?q?=20longer=20than=201=20lesson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/parser/index.js | 6 +++++- server/parser/untis.js | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/server/parser/index.js b/server/parser/index.js index 1b53e7a..d75477a 100644 --- a/server/parser/index.js +++ b/server/parser/index.js @@ -24,7 +24,8 @@ export class Parser { succeeded: true, }, }); - const plan = JSON.parse(fs.readFileSync("tmpplans.json")); + const html = fs.readFileSync("plan.html"); + const plan = parseSubstitutionPlan(html); this.insertSubstitutions(plan, event); })(); } @@ -136,6 +137,9 @@ export class Parser { "Insert / DB", `Created new substitution: S:${newSubstitution.id} C:${substitutionChange.id}` ); + // console.log("Oh no...", change); + } else { + console.log("ok"); } } } diff --git a/server/parser/untis.js b/server/parser/untis.js index 0ebea97..73fb949 100644 --- a/server/parser/untis.js +++ b/server/parser/untis.js @@ -58,7 +58,12 @@ export function parseSubstitutionPlan(html) { rowData[columntitle] = cleantext; }); - data.push(rowData); + const rawLesson = rowData.lesson; + const lessons = rawLesson.match(/\d+/g).map(Number); + for (const lesson of lessons) { + rowData.lesson = lesson; + data.push(rowData); + } }); infos.changes = data;