forked from matomo-org/matomo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compute row percentages in PHP before metrics are formatted to avoid …
…percentage formatting WARNINGS. (matomo-org#15304) * Compute row percentages in PHP before metrics are formatted to avoid percentage formatting WARNINGS. * do not fail if site summary is not available * Make sure siteSummary requests total data without segment. * Make sure proper precision is used. * try to fix tests * update expected screenshots
- Loading branch information
Showing
8 changed files
with
121 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 22 additions & 7 deletions
29
plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_ratio.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,41 @@ | ||
{% if column in properties.report_ratio_columns and (column in totals|keys or forceZero|default) -%} | ||
{% set reportTotal = totals[column]|default(0) %} | ||
{% if siteTotalRow|default is not empty %} | ||
|
||
{% if siteTotalRow is defined and siteTotalRow is not empty %} | ||
{% set siteTotal = siteTotalRow.getColumn(column) %} | ||
{% elseif siteSummary is defined and siteSummary is not empty and siteSummary.getFirstRow %} | ||
{% set siteTotal = siteSummary.getFirstRow.getColumn(column) %} | ||
{% else %} | ||
{% set siteTotal = 0 %} | ||
{% endif %} | ||
|
||
{% set rowPercentage = row.getColumn(column)|percentage(reportTotal, 1) %} | ||
{% if rowPercentage|default is empty %} | ||
{% if row.getMetadata(column ~ '_row_percentage') != false %} | ||
{% set rowPercentage = row.getMetadata(column ~ '_row_percentage') %} | ||
{% elseif row.getColumn(column)|default(0) is numeric and reportTotal is numeric %} | ||
{% set rowPercentage = row.getColumn(column)|percentage(reportTotal, 1) %} | ||
{% else %} | ||
{% set rowPercentage = '' %} {# should not happen #} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% set metricTitle = translations[column]|default(column) %} | ||
|
||
{% set reportRatioTooltip = 'General_ReportRatioTooltip'|translate(label, rowPercentage|e('html_attr'), reportTotal|e('html_attr'), metricTitle|e('html_attr'), '"' ~ segmentTitlePretty ~ '"', translations[labelColumn]|default(labelColumn)|e('html_attr')) %} | ||
|
||
{% if siteTotal and siteTotal > reportTotal %} | ||
{% set totalPercentage = row.getColumn(column)|percentage(siteTotal, 1) %} | ||
{% if totalPercentage|default is empty %} | ||
{% if row.getMetadata(column ~ '_site_total_percentage') != false %} | ||
{% set totalPercentage = row.getMetadata(column ~ '_site_total_percentage') %} | ||
{% elseif row.getColumn(column)|default(0) is numeric and siteTotal is numeric %} | ||
{% set totalPercentage = row.getColumn(column)|percentage(siteTotal, 1) %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% if totalPercentage|default is not empty %} | ||
{% set totalRatioTooltip = 'General_TotalRatioTooltip'|translate(totalPercentage, siteTotal|number(2,0), metricTitle, periodTitlePretty) %} | ||
{% else %} | ||
{% set totalRatioTooltip = '' %} | ||
{% endif %} | ||
|
||
<span class="ratio" | ||
title="{{ reportRatioTooltip|rawSafeDecoded|raw }} {{ totalRatioTooltip|rawSafeDecoded|e('html_attr') }}{% if tooltipSuffix|default is not empty %}<br/><br/> {{ tooltipSuffix|rawSafeDecoded|e('html_attr') }}{% endif %}" | ||
> {{ rowPercentage }} {% if changePercantage|default is not empty %}({{ changePercentage }}){% endif %}</span> | ||
> {{ rowPercentage }} {% if changePercentage|default is not empty %}({{ changePercentage }}){% endif %}</span> | ||
{%- endif %} |
4 changes: 2 additions & 2 deletions
4
tests/UI/expected-screenshots/GoalsTable_goals_table_abandoned_carts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/UI/expected-screenshots/GoalsTable_goals_table_ecommerce_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/UI/expected-screenshots/UIIntegrationTest_dashboard2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/UI/expected-screenshots/UIIntegrationTest_ecommerce_products.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.