From 1d91fd2dd63cd7fcbe8a9d462370d909904eebe7 Mon Sep 17 00:00:00 2001 From: Timo Besenreuther <timo.besenreuther@gmail.com> Date: Wed, 10 Apr 2013 15:25:51 +0200 Subject: [PATCH] refs #1700 time tracking * bug fix: min/max generation time didn't work in nested data tables because the column aggregation operations were not passed to sub tables * ui improvement: very small values were shown as 0s. use three decimal places if value is smaller than 10ms (e.g. display 2ms as 0.002s instead of 0s) --- core/DataTable.php | 4 +++- core/DataTable/Row.php | 1 + core/Piwik.php | 3 ++- tests/PHPUnit/Core/PiwikTest.php | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/DataTable.php b/core/DataTable.php index 656ff1c480..56879136d2 100644 --- a/core/DataTable.php +++ b/core/DataTable.php @@ -449,7 +449,9 @@ class Piwik_DataTable // if the row has the subtable already // then we have to recursively sum the subtables if (($idSubTable = $row->getIdSubDataTable()) !== null) { - $rowFound->sumSubtable(Piwik_DataTable_Manager::getInstance()->getTable($idSubTable)); + $subTable = Piwik_DataTable_Manager::getInstance()->getTable($idSubTable); + $subTable->setColumnAggregationOperations($this->columnAggregationOperations); + $rowFound->sumSubtable($subTable); } } } diff --git a/core/DataTable/Row.php b/core/DataTable/Row.php index 2a0550bd88..ff5b5de25b 100644 --- a/core/DataTable/Row.php +++ b/core/DataTable/Row.php @@ -282,6 +282,7 @@ class Piwik_DataTable_Row $thisSubTable = new Piwik_DataTable(); $this->addSubtable($thisSubTable); } + $thisSubTable->setColumnAggregationOperations($subTable->getColumnAggregationOperations()); $thisSubTable->addDataTable($subTable); } diff --git a/core/Piwik.php b/core/Piwik.php index 961f561a4e..2dd7ba9b0c 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -1437,7 +1437,8 @@ class Piwik $minutes = floor($minusDaysAndHours / 60); $seconds = $minusDaysAndHours - $minutes * 60; - $seconds = round($seconds, 2); + $precision = ($seconds > 0 && $seconds < 0.01 ? 3 : 2); + $seconds = round($seconds, $precision); if ($years > 0) { $return = sprintf(Piwik_Translate('General_YearsDays'), $years, $days); diff --git a/tests/PHPUnit/Core/PiwikTest.php b/tests/PHPUnit/Core/PiwikTest.php index a4db97b17a..ade7e91778 100644 --- a/tests/PHPUnit/Core/PiwikTest.php +++ b/tests/PHPUnit/Core/PiwikTest.php @@ -91,6 +91,7 @@ class PiwikTest extends DatabaseTestCase array(1.342, array('1.34s', '00:00:01.34')), array(.342, array('0.34s', '00:00:00.34')), array(.02, array('0.02s', '00:00:00.02')), + array(.002, array('0.002s', '00:00:00')), array(1.002, array('1s', '00:00:01')), array(1.02, array('1.02s', '00:00:01.02')), array(1.2, array('1.2s', '00:00:01.20')), -- GitLab