Skip to content
Extraits de code Groupes Projets
Valider 777fa7f0 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Refs #4200, move AddSummaryRow logic to Truncate, change AddSummaryRow logic...

Refs #4200, move AddSummaryRow logic to Truncate, change AddSummaryRow logic to just add a summary row and fix bug in FrontController.
parent 66add89b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -17,7 +17,8 @@ use Piwik\DataAccess\ArchiveSelector;
use Piwik\Period\Range;
/**
* The **Archive** class is used to query archive data.
* The **Archive** class is used to query cached analytics statistics
* (termed "archive data").
*
* You can use **Archive** instances to get archive data for one or more sites,
* for one or more periods and one optional segment.
......@@ -35,6 +36,8 @@ use Piwik\Period\Range;
* If you're creating an API that returns report data, you may want to use the
* [getDataTableFromArchive](#getDataTableFromArchive) helper function.
*
* Learn more about _archiving_ [here](#).
*
* ### Limitations
*
* - You cannot get data for multiple range periods in a single query.
......
......@@ -12,7 +12,7 @@ namespace Piwik\DataTable\Filter;
use Piwik\DataTable\Filter;
use Piwik\DataTable;
use Piwik\DataTable\Row;
use Piwik\DataTable\Row\DataTableSummaryRow;
/**
* Add a new row to the table containing a summary
......
......@@ -13,6 +13,7 @@ namespace Piwik\DataTable\Filter;
use Piwik\DataTable\Filter;
use Piwik\DataTable;
use Piwik\DataTable\Manager;
use Piwik\DataTable\Row;
/**
* @package Piwik
......@@ -47,14 +48,12 @@ class Truncate extends Filter
public function filter($table)
{
$this->addSummaryRow($table);
$table->filter('ReplaceSummaryRowLabel');
$table->queueFilter('ReplaceSummaryRowLabel');
if ($this->filterRecursive) {
foreach ($table->getRows() as $row) {
if ($row->isSubtableLoaded()) {
$idSubTable = $row->getIdSubDataTable();
$subTable = Manager::getInstance()->getTable($idSubTable);
$subTable->filter('Truncate', array($this->truncateAfter));
$this->filter($row->getSubtable());
}
}
}
......@@ -65,14 +64,14 @@ class Truncate extends Filter
$table->filter('Sort',
array($this->columnToSortByBeforeTruncating, 'desc'));
if ($table->getRowsCount() <= $this->startRowToSummarize + 1) {
if ($table->getRowsCount() <= $this->truncateAfter + 1) {
return;
}
$rows = $table->getRows();
$count = $table->getRowsCount();
$newRow = new Row();
for ($i = $this->startRowToSummarize; $i < $count; $i++) {
for ($i = $this->truncateAfter; $i < $count; $i++) {
if (!isset($rows[$i])) {
// case when the last row is a summary row, it is not indexed by $cout but by DataTable::ID_SUMMARY_ROW
$summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
......@@ -88,7 +87,7 @@ class Truncate extends Filter
$newRow->setColumns(array('label' => $this->labelSummaryRow) + $newRow->getColumns());
if ($this->deleteRows) {
$table->filter('Limit', array(0, $this->startRowToSummarize));
$table->filter('Limit', array(0, $this->truncateAfter));
}
$table->addSummaryRow($newRow);
unset($rows);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter