Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute row percentages in PHP before metrics are formatted to avoid percentage formatting WARNINGS. #15304

Merged
merged 8 commits into from Jan 3, 2020

Conversation

diosmosis
Copy link
Member

Fixes #14540

@diosmosis diosmosis added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Dec 22, 2019
@diosmosis diosmosis added this to the 3.13.1 milestone Dec 22, 2019
@tsteur
Copy link
Member

tsteur commented Dec 22, 2019

@diosmosis where can this be reproduced the previous issue?

@diosmosis
Copy link
Member Author

@@ -1,20 +1,19 @@
{% 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 %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diosmosis do you understand why we calculate the percentage differently

  • The percentage value we actually show is based on reportTotal
  • The percentage value in tooltip is based on siteTotal

I wonder if we can't always use the same logic? Eg always use reportTotal? Then we wouldn't even need to do the API call in the HTML table maybe. I suppose the reportTotal may be formatted as well though. Actually I think I get it... the siteTotal is without segment while reportTotal may have a segment...

Looks good to merge @diosmosis

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think I get it... the siteTotal is without segment while reportTotal may have a segment...

Interesting, I had no idea why this was there :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I just tested it and it does actually not seem to be the case. I reckon the siteSummary might not be needed at all and we can just use the same percentage as we show in the table based on reportTotal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is the commit that differentiated between totals & siteSummary: bb0e02d

Maybe siteSummary was supposed to get the data w/o segment, but because we weren't using Request::processRequest(..., $default = []) or something similar, it wasn't working as expected? I wonder if this is actually a bug and we can fix it by making siteSummary work the way you thought it worked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great to add the default 👍

@tsteur
Copy link
Member

tsteur commented Dec 31, 2019

LGTM @diosmosis seems like some UI tests maybe need to be updated as for some reason the hidden ratio maybe is taking more space? Maybe those tests are failing though also in 3.x... I'll restart the PR travis jobs

@diosmosis
Copy link
Member Author

@tsteur
Copy link
Member

tsteur commented Jan 1, 2020

Funny indeed since I thought this percentage was only used for the title but not for the shown value

@diosmosis diosmosis merged commit 3f760fe into 3.x-dev Jan 3, 2020
@diosmosis diosmosis deleted the ratio-percent-unformatted branch January 3, 2020 02:30
jonasgrilleres pushed a commit to 1024pix/pix-analytics that referenced this pull request Sep 22, 2020
…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
jbuget pushed a commit to 1024pix/pix-analytics that referenced this pull request Sep 26, 2020
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

warning Piwik.php(122): Warning - A non-numeric value encountered
2 participants