3d-interface/analysis/analyse.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-10-12 09:30:48 +02:00
#!/usr/bin/node
2015-10-07 16:59:10 +02:00
var lib = require('./lib.js');
2015-10-07 14:13:20 +02:00
function main(path) {
2015-09-14 16:35:16 +02:00
2015-10-07 16:59:10 +02:00
var db = lib.loadFromFile(path);
var groups = lib.makeGroups(db);
2015-09-14 16:35:16 +02:00
2015-10-12 09:30:48 +02:00
// Erase groups that are not usable
2015-10-14 10:30:18 +02:00
var invalid = 0;
2015-10-12 09:30:48 +02:00
groups = groups.filter(function(elt) {
2015-09-28 09:36:49 +02:00
2015-10-12 09:30:48 +02:00
// An elt is valid if it contains at least 2 exp, BaseRecommendation included
2015-10-14 10:30:18 +02:00
if (elt.length > 1 && elt.find(function(e) { return e.recommendation_style[4] === 'B'; }) !== undefined) {
return true
} else {
invalid++;
return false;
}
2015-09-28 09:36:49 +02:00
2015-10-07 14:13:20 +02:00
});
2015-10-07 14:13:20 +02:00
groups.forEach(function(elt) {
2015-10-12 09:30:48 +02:00
elt.sort(lib.compareRecommendationStyle);
2015-10-07 14:13:20 +02:00
});
2015-10-14 10:30:18 +02:00
var nbExp = 0;
groups.forEach(function(elt) {
nbExp += elt.length;
});
console.log(`There were ${db.users.length} users for ${nbExp} experiments (${invalid} invalid)`);
2015-10-12 09:30:48 +02:00
console.log(`There were ${groups.length} groups that were made.`);
2015-10-07 14:13:20 +02:00
2015-10-12 09:30:48 +02:00
groups.forEach(function(elt) {
console.log(elt.length);
2015-10-07 14:13:20 +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])