2015-10-02 14:44:38 +02:00
|
|
|
function main(path) {
|
2015-09-14 16:35:16 +02:00
|
|
|
|
2015-10-02 14:44:38 +02:00
|
|
|
var db = JSON.parse(require('fs').readFileSync(path, 'utf8'));
|
2015-09-14 16:35:16 +02:00
|
|
|
|
2015-09-28 09:36:49 +02:00
|
|
|
console.log('There were ' + db.users.length + ' users for ' + db.experiments.length + ' experiments');
|
|
|
|
|
|
|
|
var meanTimeNoReco = 0;
|
|
|
|
var meanTimeArrow = 0;
|
|
|
|
var meanTimeViewport = 0;
|
|
|
|
|
2015-10-02 14:44:38 +02:00
|
|
|
console.log();
|
|
|
|
|
2015-09-28 09:36:49 +02:00
|
|
|
for (var i = 0; i < db.experiments.length; i++) {
|
|
|
|
|
|
|
|
var exp = db.experiments[i];
|
|
|
|
var events = exp.elements.events;
|
|
|
|
|
|
|
|
if (events.length === 0 || exp.user.worker_id === null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-10-02 14:44:38 +02:00
|
|
|
// console.log(exp.user.worker_id + ' : ' + exp.user.rating + ' -> ' + timeToString(timeDifference(events[0].time, events[events.length-1].time)));
|
|
|
|
|
|
|
|
var coins = [];
|
|
|
|
for (var j = 0; j < exp.elements.events.length; j++) {
|
|
|
|
|
|
|
|
if (exp.elements.events[j].type === 'coin') {
|
|
|
|
|
|
|
|
if (coins.find(function(elt) { return elt.id === exp.elements.events[j].id; }) === undefined) {
|
|
|
|
|
|
|
|
coins.push(exp.elements.events[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
console.log(exp.id + ' -> ' + coins.length + ' (on ' + exp.coinCombination.scene_id + ')');
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log();
|
|
|
|
|
|
|
|
for (var i = 0; i < db.users.length; i++) {
|
|
|
|
|
|
|
|
var user = db.users[i];
|
|
|
|
console.log(user.worker_id + ' has done ' + user.experiments.length + ' experiments with rating ' + user.rating);
|
2015-09-28 09:36:49 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function timeDifference(time1, time2) {
|
|
|
|
|
|
|
|
return new Date(time2).getTime() - new Date(time1).getTime();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function timeToString(_time) {
|
|
|
|
|
|
|
|
var time = _time / 1000;
|
|
|
|
|
|
|
|
return Math.floor(time / 3600) + 'h' + Math.floor((time % 3600) / 60) + 'm' + Math.floor(time % 60);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-10-02 14:44:38 +02:00
|
|
|
if (process.argv.length !== 3) {
|
|
|
|
process.stderr.write('Error : please give me a JSON file to work on\n');
|
|
|
|
process.exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
main(process.argv[2])
|