From 9e86c7960608c42aebe1966bb368bb07cc4a34bc Mon Sep 17 00:00:00 2001
From: Thomas Steur <thomas.steur@googlemail.com>
Date: Wed, 7 May 2014 02:03:07 +0200
Subject: [PATCH] refs #4377 make sure metrics like sum_daily_nb_uniq_visitors
 (which are renamed after aggregation) are summed correctly. If period is for
 instance 2014-04-01,2014-05-01 we will sum two periods. The month of April
 2014 and May 1st. The dataTable of the month will already contain the renamed
 column (as it was aggregated before) whereas May 1st datatable will not
 contain the renamend column but the original. Both columns cannot be summed
 therefore and the original column will overwrite the value of the renamed
 column. Meaning sum_daily_nb_uniq_visitors is in this case always the value
 of May 1st

---
 core/ArchiveProcessor.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index 20c4c2df80..1c44465e5b 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -337,6 +337,12 @@ class ArchiveProcessor
             $dataTable = $this->getArchive()->getDataTable($name, $idSubTable = null);
         }
 
+        if ($dataTable instanceof Map) {
+            foreach ($dataTable->getDataTables() as $table) {
+                $this->renameColumnsAfterAggregation($table, $columnsToRenameAfterAggregation);
+            }
+        }
+
         $dataTable = $this->getAggregatedDataTableMap($dataTable, $columnsAggregationOperation);
         $this->renameColumnsAfterAggregation($dataTable, $columnsToRenameAfterAggregation);
         return $dataTable;
-- 
GitLab