🐛 Fix comparing classes and matching some entries

This commit is contained in:
2022-05-03 17:22:15 +02:00
parent e36c90786a
commit 8a61620410

View File

@ -101,13 +101,19 @@ export class Parser {
const classes = this.getSubstitutionClasses(classList, change.class);
if (classes.length == 0) classes.push(change.class || "unknown");
// Workaround no currect match possible for subsitutions of this
// type beacuse they don't have a class and a subject attribute
if (change.type == "Sondereins." && !change.subject) {
change.subject = change.notes;
}
const matchingSubstitution = knownSubstitutions.find((substitution) => {
return substitution.date == new Date(date).setUTCHours(0, 0, 0, 0) &&
substitution.type == (change.type == "Entfall")
? "cancellation"
: "change" &&
substitution.lesson == change.lesson &&
classes.every((el) => substitution.class.includes(el)) &&
classes.sort().join(",") == substitution.class.sort().join(",") &&
substitution.changedSubject == change.subject;
});
@ -119,7 +125,7 @@ export class Parser {
type: change.type == "Entfall" ? "cancellation" : "change",
lesson: parseInt(change.lesson),
changedTeacher: change.changedTeacher,
changedRoom: change.type == "Raum-Vtr." ? change.room : undefined,
changedRoom: change.room || undefined,
changedSubject: change.subject,
notes: change.notes,
removed: false,