diff options
author | Ben Burgess <88810029+bx80@users.noreply.github.com> | 2022-05-31 14:55:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-31 14:55:13 +0300 |
commit | 9a7dd7d9fdce120c80dc82ea77019e8c1a489af0 (patch) | |
tree | eecc765c193fe6a6a0a7a7eeadb4dc6e676c56c6 | |
parent | 5ee8fb2829302b9d84549faacc2137039f21bc75 (diff) |
Fix for missing formatting of conversion rate on goals reports (#19295)
* Fix missing formatting of conversion_rate on goals reports
* try to solve problem with API.get report
* updates expected test files
Co-authored-by: sgiehl <stefan@matomo.org>
5 files changed, 22 insertions, 7 deletions
diff --git a/plugins/CoreVisualizations/Visualizations/Sparklines.php b/plugins/CoreVisualizations/Visualizations/Sparklines.php index fac81dd033..402d92d322 100644 --- a/plugins/CoreVisualizations/Visualizations/Sparklines.php +++ b/plugins/CoreVisualizations/Visualizations/Sparklines.php @@ -252,7 +252,10 @@ class Sparklines extends ViewDataTable [$compareValues, $compareDescriptions, $evolutions] = $this->getValuesAndDescriptions($compareRow, $columnToUse, '_change', '_trend'); foreach ($compareValues as $i => $value) { - if ($columnMetrics[$columnToUse[$i]]) { + if (!isset($column[$i])) { + continue; + } + if (isset($columnMetrics[$column[$i]]) && $columnMetrics[$column[$i]]) { $value = $columnMetrics[$columnToUse[$i]]->format($value, $metricFormatter); } elseif (strpos($columnToUse[$i], 'revenue') !== false && $idSite > 0) { $value = $metricFormatter->getPrettyMoney($value, $idSite); diff --git a/plugins/Goals/Reports/Get.php b/plugins/Goals/Reports/Get.php index ba5f9850d9..5a3a341163 100644 --- a/plugins/Goals/Reports/Get.php +++ b/plugins/Goals/Reports/Get.php @@ -23,6 +23,7 @@ use Piwik\Piwik; use Piwik\Period\Factory as PeriodFactory; use Piwik\Plugin; use Piwik\Plugin\ViewDataTable; +use Piwik\Plugins\CoreHome\Columns\Metrics\ConversionRate; use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution; use Piwik\Plugins\CoreVisualizations\Visualizations\Sparklines; use Piwik\Plugins\Goals\Goals; @@ -138,6 +139,17 @@ class Get extends Base 'revenue' => Piwik::translate('Goals_OverallRevenue'), ]); + // Adding conversion rate as extra processed metrics ensures it will be formatted + $view->config->filters[] = function (DataTable $t) { + $extraProcessedMetrics = $t->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME); + + if (empty($extraProcessedMetrics)) { + $extraProcessedMetrics = []; + } + $extraProcessedMetrics[] = new ConversionRate(); + $t->setMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME, $extraProcessedMetrics); + }; + $allowMultiple = Common::getRequestVar('allow_multiple', 0, 'int'); if ($allowMultiple) { diff --git a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal.png b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal.png index a3288fe939..1c2f6984a5 100644 --- a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal.png +++ b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:95c851c648cf543352e78f63a6e80b425dca08d7e1c3715baf4e0c425d4b74fb -size 201716 +oid sha256:69e4b5390196b8623d414a5773a7232c61f446ff7405f4e7f2289a3dedf7f82e +size 203340 diff --git a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal_updated.png b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal_updated.png index d4787789b0..5a8a923363 100644 --- a/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal_updated.png +++ b/plugins/Goals/tests/UI/expected-screenshots/GoalsPages_individual_goal_updated.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2cf473eef5935fecea595337e53099e721c8090dbdbd99ebf1907d1b22aeaf7d -size 206484 +oid sha256:c9b14efd094a0f2668019dc7e49c8400b9ef997d8990187aad9124145ead5bb9 +size 208155 diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_dashboard2.png b/tests/UI/expected-screenshots/UIIntegrationTest_dashboard2.png index 4f019daa8b..be8c512368 100644 --- a/tests/UI/expected-screenshots/UIIntegrationTest_dashboard2.png +++ b/tests/UI/expected-screenshots/UIIntegrationTest_dashboard2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a5c24e8caab2f829ab393e0fb9344c867ebb68763f30c7c4a049206c5cc9d08a -size 1587771 +oid sha256:5d90c4ca56cbe94d3240418f0de111ee1ad2149c656f3bf438cebcbbb06bac00 +size 1591500 |