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

Add possibility to trigger the archiving only for a specific plugin #12945

Merged
merged 1 commit into from May 21, 2018

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented May 21, 2018

This feature allows a plugin to archive a specific plugin on demand.

For example if you have a plugin Foo that requires another plugin Bar to be archived with a specific segment of plugin Foo, you could do this in the archiver like this:

public function aggregateDayReport()
{
    ...
   $this->archiveBar();
}
public function aggregateMultipleReports()
{
    ...
    $this->archiveBar();
}
private function archiveBar() {
        $segment = new \Piwik\Segment('fooSegment', array($site->getId()));

        $period =  $this->getParams()->getPeriod();
        $parameters = new ArchiveProcessor\Parameters($site, $period, $segment);
        $parameters->onlyArchiveRequestedPlugin();
        $archiveLoader = new ArchiveProcessor\Loader($parameters);

        // process for each plugin as well
        $idArchive = $archiveLoader->prepareArchive('UserCountry');
}

Currently, the workaround would be to add eg ;Segments[]="visitorType==returning,visitorType==returningCustomer" to the config ini file. However, this will trigger the archiving for ALL reports even though it is only needed for one small report. This can make the difference of 3 minutes archiving time vs 50 minutes archiving time for a site.

When would this be useful? Say you are rending a segmented User Country Map like this:

$params = array($fetch = false, 'fooSegment');
$content = FrontController::getInstance()->dispatch('UserCountryMap', 'visitorMap', $params);

Then you don't want to archive all reports for this segment, but only eg UserCountry reports.

This change may be also useful for later #11974 Eg when a plugin is being installed, it could call the code from archiveBar() during activation for say the last X months. (it wouldn't 100% work though since if the plugin is activated through the browser, browser archiving would need to be enabled in this example, but it could be achieved by listening to archiving events).

I was thinking of offering a more general solution for above use case, but would wait until there are more use cases because I currently have only one use case.

Be good to have this in 3.5.1, otherwise in 3.6.0

@tsteur tsteur added c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Needs Review PRs that need a code review labels May 21, 2018
@tsteur tsteur added this to the 3.5.1 milestone May 21, 2018
@diosmosis diosmosis merged commit 497e6d0 into 3.x-dev May 21, 2018
@diosmosis diosmosis deleted the forcearchiveplugin branch May 21, 2018 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. 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