-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodfeResults.js
57 lines (52 loc) · 1.98 KB
/
odfeResults.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// ODFE results gatherer
var jsonfile = require('jsonfile');
function generateJSON(odfdir, aggname, test, key, callback) {
console.log("Figure out the production coverage results");
//Where are the results?
var resultsDir = odfdir + "public/app/records/Aggregations/" + aggname + "/";
//get the odferuns file
var odferuns = jsonfile.readFileSync(resultsDir + "odferuns.json");
var lastrun = odferuns.runs[odferuns.runs.length - 1];
console.log("Last run " + lastrun.extract);
var gauges = jsonfile.readFileSync(resultsDir + "/" + lastrun.extract + "/odfegauges.json");
console.log("Summary ")
// So what do we do with these results?
// Iterate througn the summary and get the percentages of each ns
// for elements and attributes
var nsResults = {};
nsResults.test = test;
nsResults.data = [];
var summaryHits = 0;
var summaryElements = 0;
var summaryAttrHits = 0;
var summaryAttrElements = 0;
var numNamespaces = gauges.summary.length;
for (var n = 0; n < numNamespaces; n++) {
var ns = gauges.summary[n];
var nsResult = {};
nsResult.name = ns.ns;
var elhits = ns.elementsHit[ns.elementsHit.length - 1];
summaryHits += elhits;
summaryElements += ns.elements;
nsResult.elsPct = (elhits / ns.elements) * 100;
if(ns.attributes > 0)
{
var ahits = ns.attrsHit[ns.attrsHit.length - 1];
summaryAttrHits += ahits;
summaryAttrElements += ns.attributes;
nsResult.attrPct = (ahits / ns.attributes) * 100;
} else {
nsResult.attrPct = 0;
}
nsResults.data.push(nsResult);
}
var summaryResult = {};
summaryResult.name = "Summary";
summaryResult.elsPct = (summaryHits / summaryElements) * 100;
summaryResult.attrPct = (summaryAttrHits/summaryAttrElements) * 100;
nsResults.data.push(summaryResult);
jsonfile.writeFile("results/" + "pcresults_" + key + ".json", nsResults, function (err) {
callback();
});
}
module.exports.generateJSON = generateJSON;