mirror of
https://github.com/simon987/opendirectories-bot.git
synced 2025-12-14 15:49:03 +00:00
Fixed bugs, enhanced parser
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user