checkSetup(); $core = \bootstrap::getCore(); $this->appbox = \appbox::get_instance($core); if($input->getOption('verbose')){ $logger = $this->getLogger(); $handler = new Handler\StreamHandler(fopen('php://stdout', 'a')); $logger->pushHandler($handler); $this->setLogger($logger); } $start = microtime(true); $n = 0; foreach ($this->appbox->get_databoxes() as $databox) { $subdefStructure = $databox->get_subdef_structure(); $sql = 'SELECT record_id FROM record WHERE parent_record_id = 0'; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { $record = $databox->get_record($row['record_id']); $group = $subdefStructure->getSubdefGroup($record->get_type()); if ($group) { foreach ($group as $subdef) { $todo = false; if ( ! $record->has_subdef($subdef->get_name())) { $todo = true; } if (in_array($subdef->get_name(), array('preview', 'thumbnail', 'thumbnailgif'))) { $sub = $record->get_subdef($subdef->get_name()); if ( ! $sub->is_physically_present()) { $todo = true; } } if ($todo) { $record->generate_subdefs($databox, $this->getLogger(), array($subdef->get_name())); $this->getLogger()->addInfo("generate " . $subdef->get_name() . " for record " . $record->get_record_id()); $n ++; } } } unset($record); } } $this->getLogger()->addInfo($n . " subdefs done"); $stop = microtime(true); $duration = $stop - $start; $this->getLogger()->addInfo(sprintf("process took %s, (%f sd/s.)", $this->getFormattedDuration($duration), round($n / $duration, 3))); return; } /** * Format a duration in seconds to human readable * * @param type $seconds the time to format * @return string */ public function getFormattedDuration($seconds) { $duration = round($seconds / 60) . ' minutes'; if ($duration > 60) { $duration = round($duration / 60, 1) . ' hours'; } if ($duration > 24) { $duration = round($duration / 24, 1) . ' days'; } return $duration; } }