diff --git a/server/parser/index.js b/server/parser/index.js index 1535fd6..b4766a4 100644 --- a/server/parser/index.js +++ b/server/parser/index.js @@ -34,8 +34,16 @@ export class Parser { succeeded: true, }, }); - // Insert substitutions of all substitution plans + // Group plans by date to prevent having + // multiple plan files with the same date + const dayPlans = []; for (const plan of plans) { + const foundPlan = dayPlans.find((e) => e.date == plan.date); + if (!foundPlan) dayPlans.push(plan); + else foundPlan.changes.push(...plan.changes); + } + // Insert substitutions of all substitution plans + for (const plan of dayPlans) { await this.insertSubstitutions(plan, parseEvent); } } catch (error) { @@ -77,6 +85,10 @@ export class Parser { if (change.type == "Sondereins." && !change.subject) { change.subject = change.notes; } + if (change.type == "Sondereins." && !change.teacher) { + change.teacher = change.changedTeacher; + change.changedTeacher = ""; + } // Check if a substitution exists in the database that // it similar enough to the entry in the substitution