Skip to content

Commit

Permalink
LEAF-2478 - remove the loop for the different directories since we RE…
Browse files Browse the repository at this point in the history
…ALLY only need the erm uploads, was trying to get both dirs as a nice to have
  • Loading branch information
shane committed Dec 18, 2023
1 parent 5e87203 commit a645226
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions scripts/leaf-scripts/filehistorgram.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,39 @@
fputcsv($fp, ['path', 'max (KB)', 'min (KB)', 'average (KB)', 'count']);
foreach ($portals as $portal) {

// setup our initial array
$filesizes = ['path' => $portal['site_path'], 'max' => 0, 'min' => 999999999, 'average' => 0, 'count' => 0];
$paths = [$directory . $portal['site_path'] . '/files/*.*', $portal['site_uploads'] . '*.*'];
foreach ($paths as $path) {
$glob_array = glob($path);
$filecount = count($glob_array);
$filesizes['count'] += $filecount;

foreach ($glob_array as $glob) {
$filesize = filesize($glob);
if ($filesize > 0)
$filesize = $filesize / 1024;

if ($filesize > $filesizes['max']) {
$filesizes['max'] = $filesize;
}

if ($filesize < $filesizes['min'] && $filesize > 0) {
$filesizes['min'] = $filesize;
}

if ($filesize > $totalmaxfilesize) {
$totalmaxfilesize = $filesize;
}

if ($filesize < $totalminfilesize && $filesize > 0) {
$totalminfilesize = $filesize;
}

$filesizes['average'] += $filesize;

// look at the erm uploads, if looking at multiple dirs, will need to decouple filecounts, since we mainly want to look at erm I will just look at erm.
$path = $portal['site_uploads'] . '*.*';

$glob_array = glob($path);
$filecount = count($glob_array);
$filesizes['count'] += $filecount;

foreach ($glob_array as $glob) {
$filesize = filesize($glob);
if ($filesize > 0)
$filesize = $filesize / 1024;

if ($filesize > $filesizes['max']) {
$filesizes['max'] = $filesize;
}

if ($filesize < $filesizes['min'] && $filesize > 0) {
$filesizes['min'] = $filesize;
}

if ($filesize > $totalmaxfilesize) {
$totalmaxfilesize = $filesize;
}
}

if ($filesize < $totalminfilesize && $filesize > 0) {
$totalminfilesize = $filesize;
}

$filesizes['average'] += $filesize;
}

if ($filesizes['min'] > $filesizes['max']) {
$filesizes['min'] = 0;
Expand Down

0 comments on commit a645226

Please sign in to comment.