diff --git a/backend/database.db b/backend/database.db index f5f73f4..2e622c3 100644 Binary files a/backend/database.db and b/backend/database.db differ diff --git a/backend/index.js b/backend/index.js index d9423cb..51db8b5 100644 --- a/backend/index.js +++ b/backend/index.js @@ -4,6 +4,11 @@ import bodyParser from "body-parser"; import bcrypt from "bcrypt"; import Database from "better-sqlite3"; +Date.prototype.addHours= function(h){ +this.setTime(this.getTime() + (h*60*60*1000)); + return this; +} + const app = e(); const port = 3000; const db = new Database("./database.db"); @@ -20,7 +25,8 @@ app.get('/currentRooms', (req, res) => { // req has no data // res has all room at current time console.log("currentRooms"); - let stmt = db.prepare(`SELECT * FROM TimeSlots`); + const today = new Date(); + let stmt = db.prepare(`SELECT * FROM TimeSlots INNER JOIN Rooms ON Rooms.Id=TimeSlots.Room WHERE TimeEnd BETWEEN '${today.toISOString()}' AND '${today.addHours(1).toISOString()}';`); let records = stmt.all(); res.status(200).json({records: records}); }); diff --git a/frontend/src/components/HomePage.vue b/frontend/src/components/HomePage.vue index 65870ea..3d86eaf 100644 --- a/frontend/src/components/HomePage.vue +++ b/frontend/src/components/HomePage.vue @@ -18,10 +18,9 @@ onBeforeMount(async () => {

Free Rooms:

- {{ rooms.records }}

No free rooms right now

-
\ No newline at end of file