private function calculateSize($path)
 {
     $lop = new LinuxOperationsHelper();
     $sizeByte = $lop->getSpaceUsedInDirectory($path);
     $convert = new ConvertHelper();
     return $convert->bytesToMegabytes($sizeByte);
 }
 public function update()
 {
     $directories = Config::get('mediasite')['directories'];
     $math = new Arithmetic();
     $disk = new LinuxOperationsHelper();
     $convert = new ConvertHelper();
     foreach ($directories as $directory) {
         $organisations = $disk->getFolderNamesFromDirectory($directory);
         foreach ($organisations as $organisation) {
             $sizeB = $disk->getSpaceUsedByMediasiteOrg($directory, $organisation);
             $sizeMiB = $convert->bytesToMegabytes($sizeB);
             $criteria = array(MediaSiteSchema::ORG => $organisation);
             $lastKnownUsedSize = $this->producedMoreSinceLastSave($organisation);
             if ($lastKnownUsedSize !== $sizeMiB) {
                 $storage = array(MediaSiteSchema::DATE => new MongoDate(), MediaSiteSchema::SIZE => $sizeMiB);
                 $success = $this->mongo->update($criteria, '$push', MediaSiteSchema::STORAGE, $storage, 1);
                 if ($success) {
                     $this->numberInserted = $this->numberInserted + 1;
                     $diff = $math->subtract($lastKnownUsedSize, $sizeMiB);
                     $this->LogInfo("{$diff}MiB diff for {$organisation}");
                 }
             } else {
                 $this->LogInfo("No change in storage for {$organisation}");
             }
         }
     }
     $this->LogInfo("Aggregated data and inserted {$this->numberInserted} items");
 }