update the total_disk_space function to do and sql sum on the events that already have a space assigned and only update ones that don't. This reduces ram requirements.

This commit is contained in:
Isaac Connor 2017-10-23 11:02:36 -07:00
parent a836dd5ab3
commit f99e404730
1 changed files with 3 additions and 1 deletions

View File

@ -113,7 +113,9 @@ class Storage {
if ( ! array_key_exists( 'disk_used_space', $this ) ) {
$used = 0;
if ( $this->{'Type'} == 's3fs' ) {
foreach ( Event::find_all( array( 'StorageId'=>$this->Id() ) ) as $Event ) {
$used = dbFetchOne('SELECT SUM(DiskSpace) FROM EVents WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this-Id()) );
foreach ( Event::find_all( array( 'StorageId'=>$this->Id(), 'DiskSpace'=>null ) ) as $Event ) {
$Event->Storage( $this ); // Prevent further db hit
$used += $Event->DiskSpace();
}