Browse Source

added sync chart report server, removed mongodb folder from repo

visualizer2
edoardoo 10 years ago
parent
commit
4480d8feb8
10 changed files with 33 additions and 7 deletions
  1. +2
    -1
      .gitignore
  2. BIN
      mongodb/journal/j._0
  3. BIN
      mongodb/journal/lsn
  4. BIN
      mongodb/local.0
  5. BIN
      mongodb/local.ns
  6. +0
    -1
      mongodb/mongod.lock
  7. BIN
      mongodb/visualizer.0
  8. BIN
      mongodb/visualizer.ns
  9. +14
    -2
      public/scripts/leaderBoard.js
  10. +17
    -3
      server.js

+ 2
- 1
.gitignore View File

@ -1 +1,2 @@
node_modules/
node_modules/
mongodb/

BIN
mongodb/journal/j._0 View File


BIN
mongodb/journal/lsn View File


BIN
mongodb/local.0 View File


BIN
mongodb/local.ns View File


+ 0
- 1
mongodb/mongod.lock View File

@ -1 +0,0 @@
39273

BIN
mongodb/visualizer.0 View File


BIN
mongodb/visualizer.ns View File


+ 14
- 2
public/scripts/leaderBoard.js View File

@ -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 += "<p>Updated "+hour+"h "+minutes+"m "+seconds+"s</p>";
results += "<h1>Cazziammolla Placement: "+rankings[i].rank+"</h1>";
results += "<h2>with a score of: "+rankings[i].score+"</h2>";
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 += "<tr><td>"+i+"</td><td>"+settings[i].rankings[j].rank+"</td><td>"+settings[i].rankings[j].score+"</td></tr>"
leaderBoardServerJson.settings[i] = { rank: settings[i].rankings[j].rank, score: settings[i].rankings[j].score};
}
};
};
var results = "<table><thead><th>Setting</th><th>Placement</th><th>Score</th></thead>"+results+"</table>";
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");


+ 17
- 3
server.js View File

@ -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){


Loading…
Cancel
Save