From 6444f09ae387488b7f67a0b858fd224a79f9853c Mon Sep 17 00:00:00 2001 From: minie4 Date: Tue, 3 May 2022 22:52:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Make=20history=20API=20compatible?= =?UTF-8?q?=20with=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/api/index.js | 3 +++ server/parser/index.js | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/server/api/index.js b/server/api/index.js index 41b44c1..5280acf 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -101,6 +101,9 @@ export async function getHistory(req, res) { include: { substitution: true, }, + orderBy: { + createdAt: "desc", + }, }; if (requestedClass) { prismaOptions.where.substitution.class = { has: requestedClass }; diff --git a/server/parser/index.js b/server/parser/index.js index 0eb62f1..6591696 100644 --- a/server/parser/index.js +++ b/server/parser/index.js @@ -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, }, });