PHP Class Piwik\Plugin\Archiver

Descendants should implement the {@link aggregateDayReport()} and {@link aggregateMultipleReports()} methods. Both of these methods should persist analytics data using the {@link \Piwik\ArchiveProcessor} instance returned by {@link getProcessor()}. The {@link aggregateDayReport()} method should compute analytics data using the {@link \Piwik\DataAccess\LogAggregator} instance returned by {@link getLogAggregator()}. ### Examples **Extending Archiver** class MyArchiver extends Archiver { public function aggregateDayReport() { $logAggregator = $this->getLogAggregator(); $data = $logAggregator->queryVisitsByDimension(...); $dataTable = new DataTable(); $dataTable->addRowsFromSimpleArray($data); $archiveProcessor = $this->getProcessor(); $archiveProcessor->insertBlobRecords('MyPlugin_myReport', $dataTable->getSerialized(500)); } public function aggregateMultipleReports() { $archiveProcessor = $this->getProcessor(); $archiveProcessor->aggregateDataTableRecords('MyPlugin_myReport', 500); } }
Show file Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
__construct ( Piwik\ArchiveProcessor $processor ) Constructor.
aggregateDayReport ( ) Archives data for a day period.
aggregateMultipleReports ( ) Archives data for a non-day period.
disable ( )
isEnabled ( ) : boolean Whether this Archiver should be used or not.

Protected Methods

Method Description
getLogAggregator ( ) : LogAggregator Returns a {@link Piwik\DataAccess\LogAggregator} instance that can be used to aggregate log table rows for this period, segment and site.
getProcessor ( ) : Piwik\ArchiveProcessor Returns a {@link Piwik\ArchiveProcessor} instance that can be used to insert archive data for the period, segment and site we are archiving data for.

Method Details

__construct() public method

Constructor.
public __construct ( Piwik\ArchiveProcessor $processor )
$processor Piwik\ArchiveProcessor The ArchiveProcessor instance to use when persisting archive data.

aggregateDayReport() abstract public method

Implementations of this method should do more computation intensive activities such as aggregating data across log tables. Since this method only deals w/ data logged for a day, aggregating individual log table rows isn't a problem. Doing this for any larger period, however, would cause performance degradation. Aggregate log table rows using a {@link Piwik\DataAccess\LogAggregator} instance. Get a {@link Piwik\DataAccess\LogAggregator} instance using the {@link getLogAggregator()} method.
abstract public aggregateDayReport ( )

aggregateMultipleReports() abstract public method

Implementations of this method should only aggregate existing reports of subperiods of the current period. For example, it is more efficient to aggregate reports for each day of a week than to aggregate each log entry of the week. Use {@link Piwik\ArchiveProcessor::aggregateNumericMetrics()} and {@link Piwik\ArchiveProcessor::aggregateDataTableRecords()} to aggregate archived reports. Get the {@link Piwik\ArchiveProcessor} instance using the {@link getProcessor()} method.
abstract public aggregateMultipleReports ( )

disable() public method

public disable ( )

getLogAggregator() protected method

Returns a {@link Piwik\DataAccess\LogAggregator} instance that can be used to aggregate log table rows for this period, segment and site.
protected getLogAggregator ( ) : LogAggregator
return Piwik\DataAccess\LogAggregator

getProcessor() protected method

Returns a {@link Piwik\ArchiveProcessor} instance that can be used to insert archive data for the period, segment and site we are archiving data for.
protected getProcessor ( ) : Piwik\ArchiveProcessor
return Piwik\ArchiveProcessor

isEnabled() public method

Whether this Archiver should be used or not.
public isEnabled ( ) : boolean
return boolean