diff --git a/routers/event.js b/routers/event.js index 026ec57..d52a290 100644 --- a/routers/event.js +++ b/routers/event.js @@ -24,7 +24,8 @@ event_router.get('/', (req, res) => { // Send Event Whoose Id Is given event_router.get('/:id', checkAuthenticated, async (req, res) => { // Find Event - eventSchema.findOne({ name: req.params.id }).then(async event => { + var time = new Date(); + eventSchema.findOne({ name: req.params.id }).then(async event => { // 90 ms to get event if (!event) { return res.send({ "success": false, msg: "Event not found" }) @@ -57,7 +58,7 @@ event_router.get('/:id', checkAuthenticated, async (req, res) => { }); return data; }) - + // Reorder leaderboard event.leaderboard = event.leaderboard.sort((a, b) => { let a1 = parseInt(a.points); @@ -75,7 +76,8 @@ event_router.get('/:id', checkAuthenticated, async (req, res) => { success: true, event: event, started: true, - questions: await Promise.all(questions) + questions: await Promise.all(questions), + time: (new Date() - time).toString() }) }) }) diff --git a/routers/practise.js b/routers/practise.js index 2e35421..f8b531f 100644 --- a/routers/practise.js +++ b/routers/practise.js @@ -21,6 +21,8 @@ practise_router.get('/', (req, res) => { // Return All Practise Details For The Given practise id practise_router.get('/:id', async (req, res) => { + var time = new Date(); + practiseSchema.findOne({ name: req.params.id }).then(async practise => { if (practise) { var practice = practise.questions.map(async item => { @@ -50,7 +52,8 @@ practise_router.get('/:id', async (req, res) => { }); let to_return = { success: true, - data: practice_data + data: practice_data, + time: (new Date() - time).toString() } //console.log(await to_return) res.send(to_return)