✨ Add support for other substitution types
- Store and display original substitution type text - Treat "eigenverantwortliches Arbeiten" as cancellation
This commit is contained in:
@ -177,6 +177,7 @@ export async function getSubstitutions(req, res) {
|
||||
id: element.id,
|
||||
class: element.class,
|
||||
type: element.type,
|
||||
rawType: element.rawType,
|
||||
lesson: element.lesson,
|
||||
date: new Date(element.date).getTime(),
|
||||
notes: element.notes,
|
||||
|
@ -96,15 +96,15 @@ export class Parser {
|
||||
// (Date, Type, Lesson, Classes and Subject need to be the same)
|
||||
const matchingSubstitutionId = knownSubstitutions.findIndex(
|
||||
(substitution) => {
|
||||
return substitution.date == new Date(date).setUTCHours(0, 0, 0, 0) &&
|
||||
substitution.type == (change.type == "Entfall")
|
||||
? "cancellation"
|
||||
: "change" &&
|
||||
substitution.lesson == change.lesson &&
|
||||
classes.sort().join(",") ==
|
||||
substitution.class.sort().join(",") &&
|
||||
substitution.changedSubject == change.subject &&
|
||||
substitution.teacher == (change.teacher || "");
|
||||
return (
|
||||
substitution.date.getTime() ==
|
||||
new Date(date).setUTCHours(0, 0, 0, 0) &&
|
||||
substitution.rawType == change.type &&
|
||||
substitution.lesson == change.lesson &&
|
||||
classes.sort().join(",") == substitution.class.sort().join(",") &&
|
||||
substitution.changedSubject == change.subject &&
|
||||
substitution.teacher == (change.teacher || "")
|
||||
);
|
||||
},
|
||||
);
|
||||
const matchingSubstitution = knownSubstitutions[matchingSubstitutionId];
|
||||
@ -115,7 +115,12 @@ export class Parser {
|
||||
data: {
|
||||
class: classes,
|
||||
date: new Date(date),
|
||||
type: change.type == "Entfall" ? "cancellation" : "change",
|
||||
type:
|
||||
change.type == "Entfall" ||
|
||||
change.type == "eigenverantwortliches Arbeiten"
|
||||
? "cancellation"
|
||||
: "change",
|
||||
rawType: change.type,
|
||||
lesson: parseInt(change.lesson),
|
||||
teacher: change.teacher || "",
|
||||
changedTeacher: change.changedTeacher,
|
||||
@ -133,6 +138,7 @@ export class Parser {
|
||||
changes: {
|
||||
class: classes,
|
||||
type: change.type == "Entfall" ? "cancellation" : "change",
|
||||
rawType: change.type,
|
||||
lesson: parseInt(change.lesson),
|
||||
date: new Date(date),
|
||||
notes: change.notes,
|
||||
@ -204,6 +210,7 @@ export class Parser {
|
||||
changes: {
|
||||
class: remainingSubstitution.class,
|
||||
type: remainingSubstitution.type,
|
||||
rawType: remainingSubstitution.rawType,
|
||||
lesson: remainingSubstitution.lesson,
|
||||
date: remainingSubstitution.date.getTime(),
|
||||
notes: remainingSubstitution.notes,
|
||||
|
@ -27,6 +27,7 @@ model Substitution {
|
||||
class String[]
|
||||
date DateTime
|
||||
type String
|
||||
rawType String @default("unknown")
|
||||
lesson Int
|
||||
teacher String
|
||||
changedTeacher String?
|
||||
|
Reference in New Issue
Block a user