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

Ability to change periods over which evolution graphs display in scheduled reports #13501

Merged
merged 13 commits into from Nov 12, 2018

Conversation

diosmosis
Copy link
Member

@diosmosis diosmosis commented Sep 29, 2018

Changes:

  • Add new INI config param [General] graphs_default_evolution_graph_last_days_amount to match other params.
  • Add new option to scheduled reports to allow specifying per report, what periods are displayed in evolution graphs.

Tests don't pass just yet, need to add a new file.

@diosmosis diosmosis added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Sep 29, 2018
@diosmosis diosmosis added this to the 3.6.1 milestone Sep 29, 2018
@diosmosis diosmosis added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Sep 30, 2018
@tsteur
Copy link
Member

tsteur commented Oct 2, 2018

Can we move this to 3.7.0 maybe?

@diosmosis
Copy link
Member Author

It's required for a cloud report, so if moved to 3.7.0, then we'd have to wait until 3.7.0 before it can be used.

CC @mattab

@mattab mattab modified the milestones: 3.6.1, 3.6.2 Oct 14, 2018
@mattab mattab requested a review from tsteur November 7, 2018 21:38

public static function getDefaultGraphEvolutionLastPeriods()
{
$lastPeriods = Config::getInstance()->General['graphs_default_evolution_graph_last_days_amount'];
Copy link
Member

Choose a reason for hiding this comment

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

should we maybe fail if someone configures a value <= 0? so the user can see it was not correctly changed? not needed though...

@@ -86,18 +87,22 @@ public function __construct(LoggerInterface $logger)
* @param array $reports array of reports
* @param array $parameters array of parameters
* @param bool|int $idSegment Segment Identifier
* @param bool $evolutionPeriodFor If true, evolution graphs cover each day within the period. If false, evolution graphs
Copy link
Member

Choose a reason for hiding this comment

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

I'm actually not quite understanding the difference between the two but reckon will get more clear once having a look at it.

Copy link
Member Author

Choose a reason for hiding this comment

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

$evolutionPeriodFor determines if looking within range or using lastN value. I originally only had one parameter $evolutionPeriodLastN where if it was <= 0, it would look at days within the range, but that's not really clear w/ just one parameter, so I opted for being explicit.

$originalShowEvolutionWithinSelectedPeriod = Config::getInstance()->General['graphs_show_evolution_within_selected_period'];
$originalDefaultEvolutionGraphLastPeriodsAmount = Config::getInstance()->General['graphs_default_evolution_graph_last_days_amount'];
try {
Config::getInstance()->General['graphs_show_evolution_within_selected_period'] = (bool)$report['evolution_graph_within_period'];
Copy link
Member

Choose a reason for hiding this comment

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

I haven't tested it yet but are you sure this works? I think in the past usually it was often needed to do

$general = $config->General;$general['...']=(bool)....; $config->General = $general;. Not sure if this is still a thing...

Also I'm not sure this is actually applied... without testing or looking further I would have expected this needs to be set before calling \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite);

Copy link
Member Author

Choose a reason for hiding this comment

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

I remember that was for specific versions of PHP. I can do that to be safe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note: it's used in API.getProcessedReport, but can set it before all the API calls.

Copy link
Member

Choose a reason for hiding this comment

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

I remember that was for specific versions of PHP. I can do that to be safe.

might be good. I don't really remember why it was needed or whether it's still the case. Haven't tested to write it the normal way in a while as gotten used to it :)


<div
class="row evolution-graph-period"
ng-show="manageScheduledReport.report.displayFormat == '2' || manageScheduledReport.report.displayFormat == '3'"
Copy link
Member

Choose a reason for hiding this comment

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

should this be also available for "Default) Display Report tables (Graphs only for key metrics)"?

Copy link
Member Author

Choose a reason for hiding this comment

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

It has an effect, so I added it.

@@ -53,6 +53,8 @@
"SuccessfullyUnsubscribed": "You have been successfully unsubscribed from the report %1$s.",
"UnsubscribeFooter": "To unsubscribe from this report please follow this link: %1$s",
"NoTokenProvided": "No token was provided in the URL",
"NoSubscriptionFound": "No subscription found. Maybe the report was already unsubscribed or removed."
"NoSubscriptionFound": "No subscription found. Maybe the report was already unsubscribed or removed.",
"EvolutionGraphsShowForEachInPeriod": "Evolution graphs show the evolution for %1$seach day%2$s in the last %3$s",
Copy link
Member

Choose a reason for hiding this comment

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

should it be " shows the evolution"?

Copy link
Member Author

Choose a reason for hiding this comment

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

should be 'show' since 'evolution graphs' is plural (in this case the option is for all evolution graphs in the report, which is why it's plural in the text)

@tsteur
Copy link
Member

tsteur commented Nov 8, 2018

@diosmosis I've just tried it and first error I got was The evolutionPeriodN param has no effect when evolutionPeriodFor is "each".. If I understand this correct, maybe we could just ignore the number of days when each day is selected or so?

@tsteur
Copy link
Member

tsteur commented Nov 8, 2018

image

this seems to be the default actually and as soon as I select the first option and then click create, the above error is shown.

@diosmosis
Copy link
Member Author

@tsteur Updated the PR and fixed the issue you noticed.

@tsteur
Copy link
Member

tsteur commented Nov 11, 2018

@diosmosis looks good. Be maybe great to change the config access... I reckon it be good to have a method Config::setSetting($category, $name, $value) which sets it in a save way that works cross PHP versions? Seeing myself repeat that code quite a few times...

Otherwise: I've updated to Mac OS Mojave and GD+freetype isn't working anymore so cannot test the graphs but otherwise looks good 👍

@diosmosis
Copy link
Member Author

Ok, will merge after Config::setSetting change.

@tsteur
Copy link
Member

tsteur commented Nov 12, 2018

LGTM

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants