/** * Refreshes database. * * @return void * @throws \LogicException When "$this->io" wasn't set upfront. */ public function refresh() { if (!isset($this->io)) { throw new \LogicException('The "$this->io" must be set prior to calling "$this->refresh()".'); } //ReflectionEngine::$maximumCachedFiles = 10; ReflectionEngine::init($this->detectClassLocator()); $sql = 'UPDATE Files SET Found = 0'; $this->db->perform($sql); $files = array(); $this->io->write('Searching for files ... '); foreach ($this->getFinders() as $finder) { $files = array_merge($files, array_keys(iterator_to_array($finder))); } $file_count = count($files); $this->io->writeln(array('<info>' . $file_count . ' found</info>', '')); $progress_bar = $this->io->createProgressBar($file_count + 2); $progress_bar->setMessage(''); $progress_bar->setFormat('%message%' . PHP_EOL . '%current%/%max% [%bar%] <info>%percent:3s%%</info> %elapsed:6s%/%estimated:-6s% <info>%memory:-10s%</info>'); $progress_bar->start(); foreach ($files as $file) { $progress_bar->setMessage('Processing File: <info>' . $this->removeProjectPath($file) . '</info>'); $progress_bar->display(); $this->processFile($file); $progress_bar->advance(); } $sql = 'SELECT Id FROM Files WHERE Found = 0'; $deleted_files = $this->db->fetchCol($sql); if ($deleted_files) { $progress_bar->setMessage('Deleting Files ...'); $progress_bar->display(); $sql = 'SELECT Id FROM Classes WHERE FileId IN (:file_ids)'; $deleted_classes = $this->db->fetchCol($sql, array('file_ids' => $deleted_files)); foreach ($deleted_classes as $deleted_class_id) { $this->deleteClass($deleted_class_id); } $progress_bar->advance(); } $progress_bar->setMessage('Processing Class Relations ...'); $progress_bar->display(); $this->processClassRawRelations(); $progress_bar->advance(); $progress_bar->finish(); $progress_bar->clear(); }
/** * Queries missing revision data. * * @param integer $from_revision From revision. * @param integer $to_revision To revision. * * @return void */ private function _queryRevisionData($from_revision, $to_revision) { $range_start = $from_revision; // The "io" isn't set during autocomplete. if (isset($this->_io)) { // Create progress bar for repository plugins, where data amount is known upfront. $progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / 200) + 1); $progress_bar->setMessage(' * Reading missing revisions:'); $progress_bar->setFormat('%message% %current%/%max% [%bar%] <info>%percent:3s%%</info> %elapsed:6s%/%estimated:-6s% <info>%memory:-10s%</info>'); $progress_bar->start(); } $log_command_arguments = $this->_getLogCommandArguments(); $is_verbose = isset($this->_io) && $this->_io->isVerbose(); while ($range_start <= $to_revision) { $range_end = min($range_start + 199, $to_revision); $command = $this->_repositoryConnector->getCommand('log', sprintf($log_command_arguments, $range_start, $range_end, $this->_repositoryRootUrl)); $command->setCacheDuration('10 years'); $svn_log = $command->run(); $this->_parseLog($svn_log); $range_start = $range_end + 1; if (isset($progress_bar)) { $progress_bar->advance(); } } if (isset($progress_bar)) { // Remove progress bar of repository plugins. $progress_bar->clear(); unset($progress_bar); // Create progress bar for database plugins, where data amount isn't known upfront. $progress_bar = $this->_io->createProgressBar(); $progress_bar->setMessage(' * Reading missing revisions:'); $progress_bar->setFormat('%message% %current% [%bar%] %elapsed:6s% <info>%memory:-10s%</info>'); $progress_bar->start(); foreach ($this->getDatabaseCollectorPlugins() as $plugin) { $plugin->process($from_revision, $to_revision, $progress_bar); } } else { foreach ($this->getDatabaseCollectorPlugins() as $plugin) { $plugin->process($from_revision, $to_revision); } } if (isset($progress_bar)) { $progress_bar->finish(); $this->_io->writeln(''); } if ($is_verbose) { $this->_displayPluginActivityStatistics(); } }
/** * Queries missing revision data. * * @param integer $from_revision From revision. * @param integer $to_revision To revision. * * @return void */ private function _queryRevisionData($from_revision, $to_revision) { $range_start = $from_revision; $project_url = $this->_repositoryConnector->getProjectUrl($this->_repositoryUrl); $progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / 1000)); $progress_bar->setFormat(' * Reading missing revisions: %current%/%max% [%bar%] %percent:3s%%'); $progress_bar->start(); while ($range_start < $to_revision) { $range_end = min($range_start + 1000, $to_revision); $command = $this->_repositoryConnector->getCommand('log', '-r ' . $range_start . ':' . $range_end . ' --xml --verbose --use-merge-history {' . $project_url . '}'); $this->_parseLog($command->run()); $range_start = $range_end + 1; $progress_bar->advance(); } $progress_bar->finish(); $this->_io->writeln(''); }
public function testCreateProgressBar() { $progress_bar = $this->io->createProgressBar(10); $this->assertInstanceOf('Symfony\\Component\\Console\\Helper\\ProgressBar', $progress_bar); $this->assertEquals(10, $progress_bar->getMaxSteps()); }