diff --git a/src/helpers/attendence.ts b/src/helpers/attendence.ts index 5aed945..112e21d 100644 --- a/src/helpers/attendence.ts +++ b/src/helpers/attendence.ts @@ -25,14 +25,14 @@ class Attendence { this.attendence.delete(room) } - getRoom (room: string) { + getRoom (room: string): IAttendence | undefined { return this.attendence.get(room) } summary () { - var summary: {room: string, hours: string[], notes: string}[] = [] + var summary: {room: string, hours: string[], notes: string, auto: boolean}[] = [] this.attendence.forEach((v, k) => { - summary.push({room: k, hours: v.auto.map(i => i.hour), notes: v.notes}) + summary.push({room: k, hours: v.auto.map(i => i.hour), notes: v.notes, auto: false}) }) return summary } diff --git a/src/routes/api/admin/clean.ts b/src/routes/api/admin/clean.ts index a0f48f6..29f8975 100644 --- a/src/routes/api/admin/clean.ts +++ b/src/routes/api/admin/clean.ts @@ -88,7 +88,12 @@ cleanRouter.delete('/attendence/:room', async (req, res) => { }) cleanRouter.get('/attendenceSummary', async (req, res) => { - res.send(attendence.summary()) + var allRooms = usettings.settings.rooms + var graded = (await Grade.find({date: new Date().setUTCHours(24,0,0,0)})).map(v => v.room) + var ungraded = allRooms.filter(x => !graded.includes(x)) + var summary = attendence.summary() + var unchecked: typeof summary = ungraded.filter(x => !summary.map(v => v.room).includes(x)).map(v => ({room: v, hours: [] as string[], notes: "Nie sprawdzono", auto: true})) + res.send([...summary, ...unchecked]) }) export {cleanRouter} \ No newline at end of file