Make history API compatible with frontend

This commit is contained in:
2022-05-03 22:52:13 +02:00
parent 96b1c0e959
commit 6444f09ae3
2 changed files with 14 additions and 1 deletions

View File

@ -101,6 +101,9 @@ export async function getHistory(req, res) {
include: {
substitution: true,
},
orderBy: {
createdAt: "desc",
},
};
if (requestedClass) {
prismaOptions.where.substitution.class = { has: requestedClass };

View File

@ -130,7 +130,17 @@ export class Parser {
data: {
substitutionId: newSubstitution.id,
type: "addition",
changes: {},
changes: {
class: classes,
type: change.type == "Entfall" ? "cancellation" : "change",
lesson: parseInt(change.lesson),
date: new Date(date),
change: {
teacher: change.changedTeacher,
room: change.room || undefined,
subject: change.subject,
},
},
parseEventId: parseEvent.id,
},
});