private function _generatePrettyReport(TokenRange $currentRange, $now, $rangeStartTime, $rangeTotal, $rangeProcessed, $rangeErrors, $currentRate, $rangeSkipped, $totalSkipped, $totalDuration, $averageRate, $lastKey) { $t = new TextTable(new ReportTableDecorator()); $t->appendSubHeading('Current Range ' . Shell::colourText("(" . $currentRange->id() . ")", Shell::COLOUR_FOREGROUND_LIGHT_GREY)); $t->appendRows([['Start token', $currentRange->startToken], ['End token', $currentRange->endToken], ['First key', $currentRange->firstKey], ['Last key', $currentRange->lastKey]]); $t->appendSubHeading('Range statistics'); $t->appendRows([['Processing time', DateTimeHelper::secondsToTime($now - $rangeStartTime)], ['Total items', number_format($rangeTotal)], ['Processed items', number_format($rangeProcessed)], ['Skipped', number_format($rangeSkipped)], ['Errors', number_format($rangeErrors)], ['Processing rate', number_format($currentRate) . ' items/second']]); $t->appendSubHeading('Total'); $t->appendRows([['Processing time', DateTimeHelper::secondsToTime($totalDuration)], ['Total items', number_format($this->totalItems)], ['Processed items', number_format($this->processedItems)], ['Skipped', number_format($totalSkipped)], ['Errors', number_format($this->errors)], ['Processing rate', number_format($averageRate) . ' items/second']]); $t->appendSpacer(); $t->appendRow(['Last key seen', $lastKey]); ob_start(); echo $_REQUEST['__path__'] . "\n"; echo $t; EventManager::trigger(Events::DISPLAY_REPORT_END); return ob_get_clean(); }
private function _generatePrettyReport(BucketRange $currentRange, $now, $rangeStartTime, $rangeTotal, $rangeProcessed, $currentRate, $rangeSkipped, $totalSkipped, $totalDuration, $averageRate, $lastObject) { $t = new TextTable(new ReportTableDecorator()); $t->appendSubHeading('Current Range ' . Shell::colourText("(" . $currentRange->id() . ")", Shell::COLOUR_FOREGROUND_LIGHT_GREY)); $t->appendRow(['Prefix', $currentRange->prefix]); $t->appendSubHeading('Range statistics'); $t->appendRows([['Processing time', DateTimeHelper::secondsToTime($now - $rangeStartTime)], ['Total items', number_format($rangeTotal)], ['Processed items', number_format($rangeProcessed)], ['Skipped', number_format($rangeSkipped)], ['Processing rate', number_format($currentRate) . ' items/second']]); $t->appendSubHeading('Total'); $t->appendRows([['Processing time', DateTimeHelper::secondsToTime($totalDuration)], ['Total items', number_format($this->totalItems)], ['Processed items', number_format($this->processedItems)], ['Skipped', number_format($totalSkipped)], ['Processing rate', number_format($averageRate) . ' items/second']]); $t->appendSpacer(); $t->appendRow(['Last object seen', $lastObject]); ob_start(); EventManager::trigger(Events::DISPLAY_REPORT_START); echo $t; EventManager::trigger(Events::DISPLAY_REPORT_END); return ob_get_clean(); }
private static function _listRangesWhere($where, $limit = 0) { $query = "SELECT prefix, updatedAt, hostname, error FROM %T " . "WHERE " . $where; if ($limit > 0) { $query .= " LIMIT " . $limit; } $db = BucketRange::conn(); $ranges = $db->getRows(ParseQuery::parse($db, $query, BucketRange::tableName())); $numRanges = count($ranges); if ($numRanges > 0) { $table = new TextTable(); $table->setColumnHeaders('prefix', 'updatedAt', 'hostname', 'error'); foreach ($ranges as $range) { $table->appendRow([$range->prefix, $range->updatedAt, $range->hostname, $range->error]); } echo $table; } return $numRanges; }
/** * @param TokenRange[] $ranges */ private function _displayRangeList(array $ranges) { $table = new TextTable(); $table->setColumnHeaders('id', 'updatedAt', 'hostname', 'error'); foreach ($ranges as $range) { $table->appendRow([$range->id, $range->updatedAt, $range->hostname, $range->error]); } echo $table; }