From 357fdce32556625f6fbbaf14998f25f870de6888 Mon Sep 17 00:00:00 2001 From: edoardoo Date: Sun, 9 Aug 2015 21:24:05 +0200 Subject: [PATCH] fixed timestamp undefined, maybe --- server.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 1ee03f7..fef586c 100644 --- a/server.js +++ b/server.js @@ -87,9 +87,11 @@ io.sockets.on('connection', function(socket){ leaderBoards.find().sort({timeStamp:-1}).limit(1, function(err, docs){ var parsedLb = JSON.parse(lb); - if( parsedLb.timeStamp - docs[0].timeStamp > 600000){ - leaderBoards.insert(parsedLb); - console.log("Saving stats report."); + if( typeof docs[0].timeStamp != "undefined" ){ + if( parsedLb.timeStamp - docs[0].timeStamp > 600000){ + leaderBoards.insert(parsedLb); + console.log("Saving stats report."); + } } }); //