diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2018-05-01 02:56:36 +0300 |
---|---|---|
committer | Benaka <diosmosis@users.noreply.github.com> | 2018-05-01 02:56:36 +0300 |
commit | 38c9a6dbfc722b8940df2420a0c5df35c3b589c8 (patch) | |
tree | a4a7f90906ad9201ce6e6451df059259587df894 /core/Plugin/ComputedMetric.php | |
parent | d73ba46f2d903abac5cd322affca36396d8bc046 (diff) |
Use a higher precision for rates to show more accurate percentage values (#12775)
Currently, we round to two decimals. This means when calculating the percentage (`x 100`) we show eg only 1% or 5% in custom reports. However, for conversion rates etc we should show more accurate values and therefore need to use a higher precision.
Diffstat (limited to 'core/Plugin/ComputedMetric.php')
-rw-r--r-- | core/Plugin/ComputedMetric.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/Plugin/ComputedMetric.php b/core/Plugin/ComputedMetric.php index 7825fedde3..5d0e06bc36 100644 --- a/core/Plugin/ComputedMetric.php +++ b/core/Plugin/ComputedMetric.php @@ -121,7 +121,12 @@ class ComputedMetric extends ProcessedMetric $metric1 = $this->getMetric($row, $this->metric1); $metric2 = $this->getMetric($row, $this->metric2); - return Piwik::getQuotientSafe($metric1, $metric2, $precision = 2); + $precision = 2; + if ($this->aggregation === self::AGGREGATION_RATE) { + $precision = 3; + } + + return Piwik::getQuotientSafe($metric1, $metric2, $precision); } private function getDetectedType() |