Fixed bugs, enhanced parser

This commit is contained in:
simon
2018-02-05 22:05:07 -05:00
parent f3dc1445e4
commit 23775ec126
12 changed files with 459 additions and 80 deletions

View File

@@ -23,7 +23,7 @@ function drawCharts(rData) {
for(var ext in rData["ext_sizes"]) {
//Ignore file sizes below 0.5%
if (rData["ext_sizes"][ext] < 0.005 * rData["total_size"]) {
if (!isRelevant(rData, ext)) {
otherSize += rData["ext_sizes"][ext];
otherCount += rData["ext_count"][ext];
@@ -40,6 +40,7 @@ function drawCharts(rData) {
colors.push(getRandomColor());
labels.push("other x" + otherCount + " (" + humanFileSize(otherSize) + ")");
dataSetSize.push(otherSize);
dataSetCount.push(otherCount);
}
var ctx = document.getElementById('typesChart').getContext('2d');
@@ -64,6 +65,23 @@ function drawCharts(rData) {
});
}
function isRelevant(rData, ext) {
console.log("Checking + " + ext);
console.log("total + " + rData["total_size"]);
console.log("size + " + rData["ext_count"][ext]);
console.log("min + " + 0.03 * rData["total_count"]);
if(rData["total_size"] === 0) {
return rData["ext_count"][ext] > 0.03 * rData["total_count"]
} else {
return rData["ext_sizes"][ext] > 0.005 * rData["total_size"]
}
}
/**
* https://stackoverflow.com/questions/1484506
*/
@@ -80,6 +98,11 @@ function getRandomColor() {
* https://stackoverflow.com/questions/10420352
*/
function humanFileSize(bytes) {
if(bytes === 0) {
return "? B"
}
var thresh = 1000;
if(Math.abs(bytes) < thresh) {
return bytes + ' B';