Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Get the current timestamp and fire the collect event
     $runDate = new \DateTime();
     \Event::fire('cron.collectJobs', array($runDate->getTimestamp()));
     // Get all registered Cron jobs
     $jobs = Cron::getCronJobs();
     // Get Laravel version
     $laravel = app();
     $version = $laravel::VERSION;
     if ($version < '5.2') {
         // Create the table helper with headers.
         $table = $this->getHelperSet()->get('table');
         $table->setHeaders(array('Jobname', 'Expression', 'Activated'));
         // Run through all registered jobs
         for ($i = 0; $i < count($jobs); $i++) {
             // Get current job entry
             $job = $jobs[$i];
             // If job is enabled or disable use the defined string instead of 1 or 0
             $enabled = $job['enabled'] ? 'Enabled' : 'Disabled';
             // Add this job to the table.
             $table->addRow(array($job['name'], $job['expression']->getExpression(), $enabled));
         }
     } else {
         // Create table for new Laravel versions.
         $table = new \Symfony\Component\Console\Helper\Table($this->getOutput());
         $table->setHeaders(array('Jobname', 'Expression', 'Activated'));
         $rows = [];
         // Run through all registered jobs
         for ($i = 0; $i < count($jobs); $i++) {
             // Get current job entry
             $job = $jobs[$i];
             // If job is enabled or disable use the defined string instead of 1 or 0
             $enabled = $job['enabled'] ? 'Enabled' : 'Disabled';
             array_push($rows, array($job['name'], $job['expression']->getExpression(), $enabled));
         }
         $table->setRows($rows);
     }
     // Render and output the table.
     $table->render($this->getOutput());
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $query = $input->getArgument('query');
     $fields = explode(',', $input->getOption('output'));
     $service = $this->getContainer()->get('cards_data');
     $conditions = $service->syntax($query);
     $conditions = $service->validateConditions($conditions);
     $q = $service->buildQueryFromConditions($conditions);
     $result = [];
     $rows = $service->get_search_rows($conditions, 'set');
     foreach ($rows as $card) {
         $cardinfo = $service->getCardInfo($card, false);
         $filtered = array_filter($cardinfo, function ($key) use($fields) {
             return in_array($key, $fields);
         }, ARRAY_FILTER_USE_KEY);
         $result[] = $filtered;
     }
     $table = new \Symfony\Component\Console\Helper\Table($output);
     $table->setRows($result);
     $table->render();
     $output->writeln('');
     $output->writeln(count($rows) . " cards");
 }
Ejemplo n.º 3
0
        if (!isset($result[$span['a']['title']])) {
            $result[$span['a']['title']] = [$span['a']['title'], max($span['e']) - min($span['b']), count($span['b'])];
        } else {
            $result[$span['a']['title']][1] += max($span['e']) - min($span['b']);
            $result[$span['a']['title']][2] += count($span['b']);
        }
    }
    return $result;
};
$console->register('analyze')->setDefinition(array())->setDescription('Displays the files in the given directory')->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) use($flatten_spans) {
    $file = __DIR__ . '/../local/trace_17186.json';
    $file = __DIR__ . '/../local/trace_17717.json';
    $trace = json_decode(file_get_contents($file), true);
    $appInfo = array_shift($trace['spans']);
    $output->writeln('App run info:');
    $table = new \Symfony\Component\Console\Helper\Table($output);
    $table->setRows(array(array('id', $trace['id']), array('TransactionName', $trace['tx']), array('PHP Version:', $appInfo['a']['php']), array('title:', $appInfo['a']['title'])));
    $table->render();
    $output->writeln('App Summary:');
    $table = new \Symfony\Component\Console\Helper\Table($output);
    $tableStyleRightAligned = new \Symfony\Component\Console\Helper\TableStyle();
    $tableStyleRightAligned->setPadType(STR_PAD_LEFT);
    $table->setColumnStyle(1, $tableStyleRightAligned);
    $table->setRows(array(array('compile count:', $appInfo['a']['cct'] ?? ''), array('compile Wall Time:', $appInfo['a']['cwt'] ?? ''), array('compile CPU Time:', $appInfo['a']['cpu']), array('Garbage Collection Runs:', $appInfo['a']['gc'] ?? ''), array('Garbage Collected:', $appInfo['a']['gcc'] ?? '')));
    $table->render();
    $table = new \Symfony\Component\Console\Helper\Table($output);
    $table->setHeaders(array('title', 'time', 'call count'))->setRows($flatten_spans($trace['spans']));
    $table->render();
    $output->writeln('End of command');
});
$console->run();