diff --git a/src/notif.ts b/src/notif.ts index d61d4a5..66dec64 100644 --- a/src/notif.ts +++ b/src/notif.ts @@ -41,7 +41,7 @@ export class NotifcationHelper { user: async (uname: string) => { return await this.send(message, await Notification.aggregate(userNotif(uname))) }, - room: async (room: number) => { + room: async (room: string) => { return await this.send(message, await Notification.aggregate(roomNotif(room))) }, group: async (group: string) => { diff --git a/src/pipelines/notif.ts b/src/pipelines/notif.ts index 143a6f6..a5fc5ae 100644 --- a/src/pipelines/notif.ts +++ b/src/pipelines/notif.ts @@ -11,7 +11,7 @@ function userNotif(uname: string) { return pipeline } -function roomNotif(room: number) { +function roomNotif(room: string) { var pipeline: PipelineStage[] = [ { $lookup: { diff --git a/src/routes/api/admin/clean.ts b/src/routes/api/admin/clean.ts index 01108a1..6967fb8 100644 --- a/src/routes/api/admin/clean.ts +++ b/src/routes/api/admin/clean.ts @@ -38,19 +38,19 @@ cleanRouter.get("/summary/:start/:stop", async (req, res) => { } }) data = data.map(v => v.toJSON()) - var byRoom: {[room: number]: any[]} = {} + var byRoom: {[room: string]: any[]} = {} data.forEach((v) => { let roomarray = byRoom[v.room] ? byRoom[v.room] : []; byRoom[v.room] = [...roomarray, {...v, room: undefined}] }) - var stat: {room: number, avg: number}[] = [] + var stat: {room: string, avg: number}[] = [] for (let i in byRoom) { var sum: number = 0 for (let j of byRoom[i]) { sum += j.grade } let avrg = sum/byRoom[i].length - stat.push({room: Number.parseInt(i), avg: avrg}) + stat.push({room: i, avg: avrg}) } res.send(stat) }) @@ -72,7 +72,7 @@ cleanRouter.get('/config', (req, res) => { cleanRouter.get('/attendence/:room', async (req, res) => { res.send({ - users: await User.find({room: Number(req.params.room)}, {fname: true, surname: true, _id: true}), + users: await User.find({room: req.params.room}, {fname: true, surname: true, _id: true}), attendence: attendence.getRoom(req.params.room) }) }) diff --git a/src/routes/api/admin/notif.ts b/src/routes/api/admin/notif.ts index e19454f..1c0f831 100644 --- a/src/routes/api/admin/notif.ts +++ b/src/routes/api/admin/notif.ts @@ -21,7 +21,7 @@ notifRouter.post("/send", async (req, res) => { result = await message.user(recp); break; case "room": - recp = req.body.recp.room as number + recp = req.body.recp.room as string result = await message.room(recp) break; case "all": diff --git a/src/routes/api/appRouter.ts b/src/routes/api/appRouter.ts index 0d40b22..8df0c4a 100644 --- a/src/routes/api/appRouter.ts +++ b/src/routes/api/appRouter.ts @@ -58,7 +58,7 @@ appRouter.post("/menu/:timestamp", capability.mw(Features.Menu), async (req, res }) appRouter.get("/keys", capability.mw(Features.Key), async (req, res) => { - var keys = (await Key.find({tb: {$exists: false}}, {_id: 0, room: 1, whom: 0}, {sort: {room: 1}})) + var keys = await Key.find({tb: {$exists: false}}, {_id: 0, room: 1, whom: 0}, {sort: {room: 1}}) var occ = keys.map(x=>x.room) var all = usettings.settings.keyrooms var free = all.filter(x=>!occ.includes(x)).sort().map(x => { diff --git a/src/schemas/Grade.ts b/src/schemas/Grade.ts index f7fb0ab..142f0f1 100644 --- a/src/schemas/Grade.ts +++ b/src/schemas/Grade.ts @@ -9,7 +9,7 @@ interface IGrade { grade?: number; date: Date; gradeDate?: Date; - room: number; + room: string; notes?: GradeNote[]; tips: string; } @@ -18,7 +18,7 @@ const gradeSchema = new Schema({ grade: Number, date: {type: Date, required: true}, gradeDate: Date, - room: {type: Number, required: true}, + room: {type: String, required: true}, notes: [Object], tips: String, }) diff --git a/src/usettings.ts b/src/usettings.ts index 497542f..c3f3aa8 100644 --- a/src/usettings.ts +++ b/src/usettings.ts @@ -1,7 +1,7 @@ import { readFileSync, writeFileSync } from "node:fs"; interface IUSettings { keyrooms: string[]; - rooms: number[]; + rooms: string[]; cleanThings: string[]; menu: { defaultItems: {