Skip to content

Commit

Permalink
refs #1816 this should set the correct value in case we are dealing w…
Browse files Browse the repository at this point in the history
…ith dataTable\maps, probably there will be still an issue with idSubtables
  • Loading branch information
tsteur committed Nov 20, 2013
1 parent 4c87bcd commit 4d4cbf4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
24 changes: 12 additions & 12 deletions core/API/DataTableManipulator/Totals.php
Expand Up @@ -59,18 +59,18 @@ protected function manipulateDataTable($dataTable)
return $dataTable;
}

if (empty($this->totalValues)) {
$metricsToCalculate = Metrics::getMetricIdsToProcessRatio();
$parentTable = $this->getFirstLevelDataTable($dataTable);

foreach ($metricsToCalculate as $metricId) {
if (!$this->hasDataTableMetric($parentTable, $metricId)) {
continue;
}

foreach ($parentTable->getRows() as $row) {
$this->addColumnValueToTotal($row, $metricId);
}
$this->totalValues = array();

$metricsToCalculate = Metrics::getMetricIdsToProcessRatio();
$parentTable = $this->getFirstLevelDataTable($dataTable);

foreach ($metricsToCalculate as $metricId) {
if (!$this->hasDataTableMetric($parentTable, $metricId)) {
continue;
}

foreach ($parentTable->getRows() as $row) {
$this->addColumnValueToTotal($row, $metricId);
}
}

Expand Down
20 changes: 16 additions & 4 deletions plugins/API/ProcessedReport.php
Expand Up @@ -405,6 +405,7 @@ private function handleTableReport($idSite, $dataTable, &$reportMetadata, $showR
}

$columns = $this->hideShowMetrics($columns);
$totals = array();

// $dataTable is an instance of Set when multiple periods requested
if ($dataTable instanceof DataTable\Map) {
Expand All @@ -426,15 +427,26 @@ private function handleTableReport($idSite, $dataTable, &$reportMetadata, $showR
$period = $simpleDataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLocalizedLongString();
$newReport->addTable($enhancedSimpleDataTable, $period);
$rowsMetadata->addTable($rowMetadata, $period);

if ($simpleDataTable->getMetadata('totals')) {
$simpleTotals = $this->hideShowMetrics($simpleDataTable->getMetadata('totals'));

foreach ($simpleTotals as $metric => $value) {
if (!array_key_exists($metric, $totals)) {
$totals[$metric] = $value;
} else {
$totals[$metric] += $value;
}
}
}
}
} else {
$this->removeEmptyColumns($columns, $reportMetadata, $dataTable);
list($newReport, $rowsMetadata) = $this->handleSimpleDataTable($idSite, $dataTable, $columns, $hasDimension, $showRawMetrics);
}

$totals = array();
if ($dataTable->getMetadata('totals')) {
$totals = $this->hideShowMetrics($dataTable->getMetadata('totals'));
if ($dataTable->getMetadata('totals')) {
$totals = $this->hideShowMetrics($dataTable->getMetadata('totals'));
}
}

return array(
Expand Down

0 comments on commit 4d4cbf4

Please sign in to comment.