Fix widget top 10 allegati

This commit is contained in:
Luca 2022-10-06 13:30:07 +02:00
parent c3e9dbf8c2
commit ad4753664a
2 changed files with 15 additions and 14 deletions

View File

@ -279,16 +279,16 @@ switch (filter('op')) {
]; ];
foreach ($dirs as $dir => $description) { foreach ($dirs as $dir => $description) {
$size = FileSystem::folderSize($dir, ['htaccess']); $size = FileSystem::folderSize($dir, ['htaccess','gitkeep','ini','xml']);
$results[] = [ $results[] = [
'description' => $description, 'description' => $description,
'size' => $size, 'size' => $size,
'formattedSize' => FileSystem::formatBytes($size), 'formattedSize' => FileSystem::formatBytes($size),
'count' => FileSystem::fileCount($dir, ['htaccess']) ?: 0, 'count' => FileSystem::fileCount($dir, ['htaccess','gitkeep','ini','xml']) ?: 0,
'dbSize' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT SUM(`size`) AS dbsize FROM zz_files')['dbsize'] : '', 'dbSize' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT SUM(`size`) AS dbsize FROM zz_files')['dbsize'] : 0,
'dbCount' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT COUNT(`id`) AS dbcount FROM zz_files')['dbcount'] : '', 'dbCount' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT COUNT(`id`) AS dbcount FROM zz_files')['dbcount'] : 0,
'dbExtensions' => ($description == 'Allegati') ? $dbo->fetchArray("SELECT SUBSTRING_INDEX(filename, '.', -1) AS extension, COUNT(*) AS num FROM zz_files GROUP BY extension ORDER BY num DESC LIMIT 10") : '', 'dbExtensions' => ($description == 'Allegati') ? $dbo->fetchArray("SELECT SUBSTRING_INDEX(filename, '.', -1) AS extension, COUNT(*) AS num FROM zz_files GROUP BY extension ORDER BY num DESC LIMIT 10") : 0,
]; ];
} }

View File

@ -51,38 +51,39 @@ function crea_grafico(values){
$data = []; $data = [];
$labels = []; $labels = [];
values.forEach(function(element) { values.forEach(function(element) {
$data.push(element.size); $data.push(element.size);
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB //Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
if (element.dbSize!==""){ if (element.dbSize>0 && element.description == "Allegati"){
if (element.size<element.dbSize){ if (element.size<element.dbSize){
var diff = (element.dbSize-element.size); var diff = (element.dbSize-element.size);
if (diff>1000){ if (diff>1000){
$("#message").append("<div class=\"label label-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+formatBytes(diff)+" di file mancanti per allegati.</div><br>"); $("#message").append("<div class=\"label label-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+formatBytes(diff)+" di files mancanti per allegati.</div><br>");
} }
} }
} }
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB //Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
if (element.dbCount!==""){ if (element.dbCount>0 && element.description == "Allegati" ){
if (element.count<element.dbCount){ if (element.count<element.dbCount){
var diff = (element.dbCount-element.count); var diff = (element.dbCount-element.count);
$("#message").append("<div class=\"label label-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+diff+" file non trovati sul disco.</div><br>"); $("#message").append("<div class=\"label label-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+diff+" files non trovati sul disco per allegati.</div><br>");
} }
} }
//Numero di file in Allegati per estensione //Numero di file in Allegati suddivisi per estensione
if (element.dbExtensions.length > 0){ if (element.dbExtensions.length > 0){
$("#message").append("<br><p><b>Top 10 allegati:</b></p>"); $("#message").append("<br><p><b>Top 10 allegati:</b></p>");
element.dbExtensions.forEach(function(extension) { element.dbExtensions.forEach(function(ext) {
$("#message").append("<div class=\"label label-info\" ><i class=\"fa fa-file\" aria-hidden=\"true\"></i> <b>"+ext["num"]+"</b> files con estensione <b>"+ext["extension"]+"</b>.</div><br>");
$("#message").append("<div class=\"label label-info\" ><i class=\"fa fa-file\" aria-hidden=\"true\"></i> <b>"+extension["NUM"]+"</b> file con estensione <b>"+extension["EXTENSION"]+"</b>.</div><br>");
}); });