✨ Add support for multiple remote timetables
- Add timetable "title" column to db - Make API return array of timetables - Add settings page for selecting a timetable - Add InfoCard if no timetable is selected
This commit is contained in:
@ -13,7 +13,7 @@ export async function getTimetable(req, res) {
|
||||
return;
|
||||
}
|
||||
const requestedClass = req.query.class.toLowerCase();
|
||||
const timetable = await prisma.timetable.findFirst({
|
||||
const timetables = await prisma.timetable.findMany({
|
||||
where: {
|
||||
class: requestedClass,
|
||||
},
|
||||
@ -22,19 +22,9 @@ export async function getTimetable(req, res) {
|
||||
},
|
||||
});
|
||||
const times = await prisma.time.findMany();
|
||||
if (!timetable) {
|
||||
res.status(404).send({
|
||||
success: false,
|
||||
error: "no_timetable",
|
||||
message: "No timetable was found for this class",
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.send({
|
||||
trusted: timetable.trusted,
|
||||
source: timetable.source,
|
||||
data: timetable.data,
|
||||
times: times,
|
||||
timetables,
|
||||
times,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ datasource db {
|
||||
|
||||
model Timetable {
|
||||
id Int @id @unique @default(autoincrement())
|
||||
title String @default("Default")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
class String
|
||||
|
Reference in New Issue
Block a user