Summarize OS

This commit is contained in:
Jakob Borg
2014-06-20 23:24:27 +02:00
parent ec85c9fdfe
commit 113b110ab4
3 changed files with 40 additions and 2 deletions

View File

@@ -34,11 +34,27 @@ reports.controller('ReportsCtrl', function ($scope, $http) {
$scope.versions = sortedList(data.versions);
$scope.platforms = sortedList(data.platforms);
var os = aggregate(data.platforms, function (x) {return x.replace(/-.*/, '');})
$scope.os = sortedList(os);
}).error(function () {
$scope.failure = true;
});
});
function aggregate(d, f) {
var r = {};
for (var o in d) {
var k = f(o);
if (k in r) {
r[k] += d[o];
} else {
r[k] = d[o];
}
}
return r;
}
function sortedList(d) {
var l = [];
var tot = 0;