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

Ensure insight reports uses the correct compare period number for periods other than day #15103

Merged
merged 1 commit into from Nov 6, 2019

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Nov 4, 2019

When viewing a insight report for a period other than day it might happen, that the report shows an error like this:

image

This happens when someone chooses to compare to same day in last year when viewing a day report and switching to another period afterwards.

When switching the compared date this setting is stored in the report options. When switching to another period like month, it tries to compare the current month to the month 365 months ago, as the stored option will be used.

As all periods except day should always compare to the last period before. This fix should solve this issue.

@sgiehl sgiehl added Bug For errors / faults / flaws / inconsistencies etc. Needs Review PRs that need a code review labels Nov 4, 2019
@sgiehl sgiehl added this to the 3.13.0 milestone Nov 4, 2019
@@ -59,6 +59,17 @@ public function beforeLoadDataTable()
);
}

private function getComparedToXPeriodsAgo()
{
$period = Common::getRequestVar('period', null, 'string');
Copy link
Member

Choose a reason for hiding this comment

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

@sgiehl took me a while to understand what is happening here and seeing no Range::getDateXPeriodsAgo() is converting eg indeed 365 to 365 months ago. From what I see week and year only can compare to the previous period, but compared_to_x_periods_ago can be 1 or 12 for months. Would we need to convert eg a number 365 to 12 instead of 1 when the period is month?

Also probably not needed but could maybe have a side effect... (probs not and only if plugins where to maybe hook into it somehow or so)... Would we maybe need to change $this->requestConfig->compared_to_x_periods_ago in above code and set the updated value to comparedToXPeriods? I don't think it's actually used in any way but may be better.

Copy link
Member Author

Choose a reason for hiding this comment

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

added another condition for month to fix that

@tsteur tsteur merged commit dd535a1 into 3.x-dev Nov 6, 2019
@tsteur tsteur deleted the fixinsightreport branch November 6, 2019 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants