Skip to content

Commit 52873b5

Browse files
ChristophBodensteinChristophBodenstein
authored andcommitted
added percentage of done simulations
1 parent eb9016d commit 52873b5

File tree

2 files changed

+34
-30
lines changed

2 files changed

+34
-30
lines changed

TOEDistributionServer/src/node/tns/routes/index.js

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,47 @@ router.get('/', function (req, res) {
3434
} else {
3535
//console.log("Will try to count open simulations.");
3636
if (result != null) {
37-
result.count(function (err, count){
37+
result.count(function (err, count){
3838
if(err){
3939
console.log("Error counting open simulations.");
4040
} else{
4141
openSimulations=count;
4242
//console.log("Number of open Simulations is:"+openSimulations);
43+
44+
simlist.find({simulated: true}, function (err, result) {
45+
if (err) {
46+
console.log("Error finding done simulations in db.");
47+
} else {
48+
//console.log("Will try to count open simulations.");
49+
if (result != null) {
50+
result.count(function (err, count){
51+
if(err){
52+
console.log("Error counting done simulations.");
53+
} else {
54+
doneSimulations=count;
55+
//console.log("Number of done Simulations is:"+doneSimulations);
56+
57+
removeOldClientsFromList(db, function (error) {
58+
res.render('index', {
59+
title: 'TimeNET distribution server',
60+
clientcount: Math.round(global.clientcount),
61+
clientsrunning: global.clientsrunning,
62+
opensimulations: openSimulations,
63+
donesimulations: doneSimulations,
64+
percentagedone: Math.round((doneSimulations *100)/(doneSimulations+openSimulations) ) || 0
65+
});
66+
67+
});
68+
}
69+
});
70+
}//End if
71+
}//End else
72+
});
4373
}
4474
});
4575
}//End if
4676
}//End else
4777
});
48-
simlist.find({simulated: true}, function (err, result) {
49-
if (err) {
50-
console.log("Error finding done simulations in db.");
51-
} else {
52-
//console.log("Will try to count open simulations.");
53-
if (result != null) {
54-
result.count(function (err, count){
55-
if(err){
56-
console.log("Error counting done simulations.");
57-
} else{
58-
doneSimulations=count;
59-
//console.log("Number of done Simulations is:"+doneSimulations);
60-
}
61-
});
62-
}//End if
63-
}//End else
64-
});
65-
66-
removeOldClientsFromList(db, function (error) {
67-
res.render('index', {
68-
title: 'TimeNET distribution server',
69-
clientcount: Math.round(global.clientcount),
70-
clientsrunning: global.clientsrunning,
71-
opensimulations: openSimulations,
72-
donesimulations: doneSimulations
73-
});
74-
75-
});
76-
7778
});
7879

7980

TOEDistributionServer/src/node/tns/views/index.jade

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ block content
1515

1616
#donesimulations
1717
p #{donesimulations} simulations done (current).
18+
19+
#precentage
20+
p #{percentagedone}% simulations done (current).
1821

1922
div
2023
form(name="reset", action="/reset", method="post")

0 commit comments

Comments
 (0)