Skip to content

Commit

Permalink
add ms logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gamer-1478 committed Apr 7, 2022
1 parent b9e7b72 commit 8277319
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions routers/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" })
Expand Down Expand Up @@ -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);
Expand All @@ -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()
})
})
})
Expand Down
5 changes: 4 additions & 1 deletion routers/practise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8277319

Please sign in to comment.