diff --git a/.gitignore b/.gitignore
index 40b878d..29d0166 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-node_modules/
\ No newline at end of file
+node_modules/
+mongodb/
\ No newline at end of file
diff --git a/mongodb/journal/j._0 b/mongodb/journal/j._0
deleted file mode 100644
index 336fa42..0000000
Binary files a/mongodb/journal/j._0 and /dev/null differ
diff --git a/mongodb/journal/lsn b/mongodb/journal/lsn
deleted file mode 100644
index f24174a..0000000
Binary files a/mongodb/journal/lsn and /dev/null differ
diff --git a/mongodb/local.0 b/mongodb/local.0
deleted file mode 100644
index 3e0abea..0000000
Binary files a/mongodb/local.0 and /dev/null differ
diff --git a/mongodb/local.ns b/mongodb/local.ns
deleted file mode 100644
index 24f2d78..0000000
Binary files a/mongodb/local.ns and /dev/null differ
diff --git a/mongodb/mongod.lock b/mongodb/mongod.lock
deleted file mode 100755
index a943521..0000000
--- a/mongodb/mongod.lock
+++ /dev/null
@@ -1 +0,0 @@
-39273
diff --git a/mongodb/visualizer.0 b/mongodb/visualizer.0
deleted file mode 100644
index ffad20d..0000000
Binary files a/mongodb/visualizer.0 and /dev/null differ
diff --git a/mongodb/visualizer.ns b/mongodb/visualizer.ns
deleted file mode 100644
index ef26edb..0000000
Binary files a/mongodb/visualizer.ns and /dev/null differ
diff --git a/public/scripts/leaderBoard.js b/public/scripts/leaderBoard.js
index cdb0b59..0cb4f22 100644
--- a/public/scripts/leaderBoard.js
+++ b/public/scripts/leaderBoard.js
@@ -16,6 +16,8 @@ function populateBoard(){
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hour = date.getHours();
+ var leaderBoardServerJson = {};
+ leaderBoardServerJson.timeStamp = date.getTime();
for (var i = rankings.length - 1; i >= 0; i--) {
if( rankings[i].teamId == 235 ){
@@ -23,6 +25,10 @@ function populateBoard(){
results += "
Updated "+hour+"h "+minutes+"m "+seconds+"s
";
results += "Cazziammolla Placement: "+rankings[i].rank+"
";
results += "with a score of: "+rankings[i].score+"
";
+
+ leaderBoardServerJson.placement = rankings[i].rank;
+ leaderBoardServerJson.score = rankings[i].score;
+
if (rankings[i].rank != points && points != 0){
ringTheBell();
}
@@ -30,17 +36,24 @@ function populateBoard(){
}
};
-
+ leaderBoardServerJson.settings = [];
var settings = data.data.settings;
for (var i = 0; i < settings.length; i++) {
for (var j = settings[i].rankings.length - 1; j >= 0; j--) {
if(settings[i].rankings[j].teamId == 235){
results += ""+i+" | "+settings[i].rankings[j].rank+" | "+settings[i].rankings[j].score+" |
"
+ leaderBoardServerJson.settings[i] = { rank: settings[i].rankings[j].rank, score: settings[i].rankings[j].score};
}
};
};
var results = "Setting | Placement | Score | "+results+"
";
listBoard.innerHTML = results;
+ try{
+ socket.emit('leaderBoard', JSON.stringify( leaderBoardServerJson));
+
+ }catch(e){
+ console.log("error");
+ }
}
@@ -50,7 +63,6 @@ function updateLeaderBoard(){
var intervalID = setInterval( function(){
loadRankingJs('https://davar.icfpcontest.org/rankings.js?cachebuster='+ new Date().getTime());
}, 30000);
- console.dir(intervalID);
}
function loadRankingJs(scriptName) {
var rankingScript = document.getElementById("rankingScript");
diff --git a/server.js b/server.js
index 9bd09c0..1ee03f7 100644
--- a/server.js
+++ b/server.js
@@ -11,6 +11,7 @@ app.use(express.static('./public'));
var mongoUri = "mongodb://localhost:27017/visualizer";
var db = mongojs( mongoUri );
var honeyCombs = db.collection('honeyCombs');
+var leaderBoards = db.collection('leaderBoards');
// honeyCombs.insert({dio: "cane", type: "flyingPig"});
//Specifying the public folder of the server to make the html accesible using the static middleware
@@ -76,11 +77,24 @@ io.sockets.on('connection', function(socket){
}
});
socket.on('jsonToParse', function(msg){
- console.log('Json received.');
- saveQuery(msg);
- // socket.emit("jsonHoneycomb", msg);
+ console.log('Json received.');
+ saveQuery(msg);
+ // socket.emit("jsonHoneycomb", msg);
});
+ socket.on('leaderBoard',function(lb){
+
+ 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.");
+ }
+ });
+ //
+
+ });
});
function saveQuery(query){