diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-05 03:25:11 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-05 03:25:11 +0400 |
commit | e8bec0896a46eb883f971bdffe8a7f15e4a1381a (patch) | |
tree | 9c304f3bdd9ffad94cbfcb839a8a7722b46a55e1 | |
parent | 2bf4ee763c8be29286b45c9118737d41a584119d (diff) |
Refs #4278 Remove Archiver hooks and the classes Archiver will be automatically detected.
-rw-r--r-- | core/Archive.php | 6 | ||||
-rw-r--r-- | core/ArchiveProcessor.php | 370 | ||||
-rw-r--r-- | core/ArchiveProcessor/Aggregator.php | 364 | ||||
-rw-r--r-- | core/ArchiveProcessor/Day.php | 77 | ||||
-rw-r--r-- | core/Plugin/Archiver.php | 26 | ||||
-rw-r--r-- | core/Plugin/Manager.php | 2 | ||||
-rw-r--r-- | plugins/Actions/Actions.php | 24 | ||||
-rw-r--r-- | plugins/Actions/Archiver.php | 1 | ||||
-rw-r--r-- | plugins/CustomVariables/CustomVariables.php | 21 | ||||
-rw-r--r-- | plugins/DevicesDetection/DevicesDetection.php | 18 | ||||
-rw-r--r-- | plugins/Goals/Goals.php | 24 | ||||
-rw-r--r-- | plugins/Provider/Provider.php | 21 | ||||
-rw-r--r-- | plugins/Referrers/Referrers.php | 25 | ||||
-rw-r--r-- | plugins/Transitions/API.php | 2 | ||||
-rw-r--r-- | plugins/UserCountry/UserCountry.php | 18 | ||||
-rw-r--r-- | plugins/UserSettings/Archiver.php | 8 | ||||
-rw-r--r-- | plugins/UserSettings/UserSettings.php | 25 | ||||
-rw-r--r-- | plugins/VisitTime/VisitTime.php | 18 | ||||
-rw-r--r-- | plugins/VisitorInterest/VisitorInterest.php | 18 | ||||
-rw-r--r-- | tests/PHPUnit/Core/ArchiveProcessingTest.php | 7 |
20 files changed, 377 insertions, 698 deletions
diff --git a/core/Archive.php b/core/Archive.php index fa0528e083..1086d9ba36 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -610,11 +610,7 @@ class Archive continue; } - if ($period->getLabel() == 'day') { - $processing = new ArchiveProcessor\Day($period, $site, $this->params->getSegment()); - } else { - $processing = new ArchiveProcessor\Aggregator($period, $site, $this->params->getSegment()); - } + $processing = new ArchiveProcessor($period, $site, $this->params->getSegment()); // process for each plugin as well foreach ($archiveGroups as $plugin) { diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php index 5abf84ca07..7b1ca233f3 100644 --- a/core/ArchiveProcessor.php +++ b/core/ArchiveProcessor.php @@ -16,8 +16,10 @@ use Piwik\DataAccess\ArchiveSelector; use Piwik\DataAccess\ArchiveWriter; use Piwik\DataAccess\LogAggregator; +use Piwik\DataTable\Manager; use Piwik\Db; use Piwik\Period; +use Piwik\Plugin\Archiver; /** * Used to insert numeric and blob archive data. @@ -53,7 +55,7 @@ use Piwik\Period; * **Inserting numeric data** * * // function in an Archiver descendent - * public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) + * public function aggregateDayReport(ArchiveProcessor $archiveProcessor) * { * $myFancyMetric = // ... calculate the metric value ... * $archiveProcessor->insertNumericRecord('MyPlugin_myFancyMetric', $myFancyMetric); @@ -62,7 +64,7 @@ use Piwik\Period; * **Inserting serialized DataTables** * * // function in an Archiver descendent - * public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) + * public function aggregateDayReport(ArchiveProcessor $archiveProcessor) * { * $maxRowsInTable = Config::getInstance()->General['datatable_archiving_maximum_rows_standard'];j * @@ -78,7 +80,7 @@ use Piwik\Period; * @package Piwik * @subpackage ArchiveProcessor */ -abstract class ArchiveProcessor +class ArchiveProcessor { /** * Flag stored at the end of the archiving @@ -365,8 +367,11 @@ abstract class ArchiveProcessor || $this->doesRequestedPluginIncludeVisitsSummary($requestedPlugin) || $enforceProcessCoreMetricsOnly ) { - $metrics = $this->aggregateCoreVisitsMetrics(); - + if($this->isDayArchive()) { + $metrics = $this->aggregateDayVisitsMetrics(); + } else { + $metrics = $this->aggregateMultipleVisitMetrics(); + } if (empty($metrics)) { $this->setNumberOfVisits(false); } else { @@ -418,8 +423,6 @@ abstract class ArchiveProcessor return $this->temporaryArchive; } - abstract protected function aggregateCoreVisitsMetrics(); - /** * @param $requestedPlugin */ @@ -442,10 +445,60 @@ abstract class ArchiveProcessor } /** + * @var Archiver[] $archivers + */ + private static $archivers = array(); + + + /** + * Loads Archiver class from any plugin that defines one. + * + * @return Plugin\Archiver[] + */ + protected function getPluginArchivers() + { + if (empty(static::$archivers)) { + $pluginNames = Plugin\Manager::getInstance()->getLoadedPluginsName(); + $archivers = array(); + foreach ($pluginNames as $pluginName) { + $archivers[$pluginName] = self::getPluginArchiverClass($pluginName); + } + static::$archivers = array_filter($archivers); + } + return static::$archivers; + } + + private static function getPluginArchiverClass($pluginName) + { + $klassName = 'Piwik\\Plugins\\' . $pluginName . '\\Archiver'; + if (class_exists($klassName) + && is_subclass_of($klassName, 'Piwik\\Plugin\\Archiver')) { + return $klassName; + } + return false; + } + + /** * This methods reads the subperiods if necessary, * and computes the archive of the current period. */ - abstract protected function compute(); + protected function compute() + { + $archivers = $this->getPluginArchivers(); + + foreach($archivers as $archiverClass) { + /** @var Archiver $archiver */ + $archiver = new $archiverClass( $this ); + + if($archiver->shouldArchive()) { + if($this->isDayArchive()) { + $archiver->aggregateDayReport(); + } else { + $archiver->aggregateMultipleReports(); + } + } + } + } protected static function determineIfArchivePermanent(Date $dateEnd) { @@ -545,4 +598,303 @@ abstract class ArchiveProcessor { return $this->requestedPlugin; } -}
\ No newline at end of file + + /** + * @return bool + */ + protected function isDayArchive() + { + return $this->getPeriod()->getLabel() == 'day'; + } + + + protected function aggregateMultipleVisitMetrics() + { + $toSum = Metrics::getVisitsMetricNames(); + $metrics = $this->aggregateNumericMetrics($toSum); + return $metrics; + } + + + protected function aggregateDayVisitsMetrics() + { + $query = $this->getLogAggregator()->queryVisitsByDimension(); + $data = $query->fetch(); + + $metrics = $this->convertMetricsIdToName($data); + $this->insertNumericRecords($metrics); + return $metrics; + } + + protected function convertMetricsIdToName($data) + { + $metrics = array(); + foreach ($data as $metricId => $value) { + $readableMetric = Metrics::$mappingFromIdToName[$metricId]; + $metrics[$readableMetric] = $value; + } + return $metrics; + } + + + /** + * Array of (column name before => column name renamed) of the columns for which sum operation is invalid. + * These columns will be renamed as per this mapping. + * @var array + */ + protected static $invalidSummedColumnNameToRenamedName = array( + Metrics::INDEX_NB_UNIQ_VISITORS => Metrics::INDEX_SUM_DAILY_NB_UNIQ_VISITORS + ); + + /** + * @var Archive + */ + protected $archive = null; + + /** + * Sums records for every subperiod of the current period and inserts the result as the record + * for this period. + * + * DataTables are summed recursively so subtables will be summed as well. + * + * @param string|array $recordNames Name(s) of the report we are aggregating, eg, `'Referrers_type'`. + * @param int $maximumRowsInDataTableLevelZero Maximum number of rows allowed in the top level DataTable. + * @param int $maximumRowsInSubDataTable Maximum number of rows allowed in each subtable. + * @param string $columnToSortByBeforeTruncation The name of the column to sort by before truncating a DataTable. + * @param array $columnAggregationOperations Operations for aggregating columns, @see Row::sumRow(). + * @param array $invalidSummedColumnNameToRenamedName For columns that must change names when summed because they + * cannot be summed, eg, + * `array('nb_uniq_visitors' => 'sum_daily_nb_uniq_visitors')`. + * @return array Returns the row counts of each aggregated report before truncation, eg, + * ``` + * array( + * 'report1' => array('level0' => $report1->getRowsCount, + * 'recursive' => $report1->getRowsCountRecursive()), + * 'report2' => array('level0' => $report2->getRowsCount, + * 'recursive' => $report2->getRowsCountRecursive()), + * ... + * ) + * ``` + */ + public function aggregateDataTableRecords($recordNames, + $maximumRowsInDataTableLevelZero = null, + $maximumRowsInSubDataTable = null, + $columnToSortByBeforeTruncation = null, + &$columnAggregationOperations = null, + $invalidSummedColumnNameToRenamedName = null) + { + // We clean up below all tables created during this function call (and recursive calls) + $latestUsedTableId = Manager::getInstance()->getMostRecentTableId(); + if (!is_array($recordNames)) { + $recordNames = array($recordNames); + } + $this->initArchive(); + $nameToCount = array(); + foreach ($recordNames as $recordName) { + $table = $this->getRecordDataTableSum($recordName, $invalidSummedColumnNameToRenamedName, $columnAggregationOperations); + + $nameToCount[$recordName]['level0'] = $table->getRowsCount(); + $nameToCount[$recordName]['recursive'] = $table->getRowsCountRecursive(); + + $blob = $table->getSerialized($maximumRowsInDataTableLevelZero, $maximumRowsInSubDataTable, $columnToSortByBeforeTruncation); + Common::destroy($table); + $this->insertBlobRecord($recordName, $blob); + } + Manager::getInstance()->deleteAll($latestUsedTableId); + + return $nameToCount; + } + + /** + * Aggregates metrics for every subperiod of the current period and inserts the result + * as the metric for this period. + * + * @param array|string $columns Array of metric names to aggregate. + * @param bool|string $operationToApply The operation to apply to the metric. Either `'sum'`, `'max'` or `'min'`. + * @return array|int Returns the array of aggregate values. If only one metric was aggregated, + * the aggregate value will be returned as is, not in an array. + * For example, if `array('nb_visits', 'nb_hits')` is supplied for `$columns`, + * ``` + * array( + * 'nb_visits' => 3040, + * 'nb_hits' => 405 + * ) + * ``` + * is returned. + */ + public function aggregateNumericMetrics($columns, $operationToApply = false) + { + if (!is_array($columns)) { + $columns = array($columns); + } + $this->initArchive(); + $data = $this->archive->getNumeric($columns); + $operationForColumn = $this->getOperationForColumns($columns, $operationToApply); + $results = $this->aggregateDataArray($data, $operationForColumn); + $results = $this->defaultColumnsToZero($columns, $results); + $this->enrichWithUniqueVisitorsMetric($results); + + foreach ($results as $name => $value) { + $this->archiveWriter->insertRecord($name, $value); + } + + // if asked for only one field to sum + if (count($results) == 1) { + return reset($results); + } + + // returns the array of records once summed + return $results; + } + + protected function initArchive() + { + if (empty($this->archive)) { + $subPeriods = $this->getPeriod()->getSubperiods(); + $this->archive = Archive::factory($this->getSegment(), $subPeriods, array($this->getSite()->getId())); + } + } + + /** + * This method selects all DataTables that have the name $name over the period. + * All these DataTables are then added together, and the resulting DataTable is returned. + * + * @param string $name + * @param array $invalidSummedColumnNameToRenamedName columns in the array (old name, new name) to be renamed as the sum operation is not valid on them (eg. nb_uniq_visitors->sum_daily_nb_uniq_visitors) + * @param array $columnAggregationOperations Operations for aggregating columns, @see Row::sumRow() + * @return DataTable + */ + protected function getRecordDataTableSum($name, $invalidSummedColumnNameToRenamedName, $columnAggregationOperations = null) + { + $table = new DataTable(); + if (!empty($columnAggregationOperations)) { + $table->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnAggregationOperations); + } + + $data = $this->archive->getDataTableExpanded($name, $idSubTable = null, $depth = null, $addMetadataSubtableId = false); + if ($data instanceof DataTable\Map) { + foreach ($data->getDataTables() as $date => $tableToSum) { + $table->addDataTable($tableToSum); + } + } else { + $table->addDataTable($data); + } + + if (is_null($invalidSummedColumnNameToRenamedName)) { + $invalidSummedColumnNameToRenamedName = self::$invalidSummedColumnNameToRenamedName; + } + foreach ($invalidSummedColumnNameToRenamedName as $oldName => $newName) { + $table->renameColumn($oldName, $newName); + } + return $table; + } + + protected function getOperationForColumns($columns, $defaultOperation) + { + $operationForColumn = array(); + foreach ($columns as $name) { + $operation = $defaultOperation; + if (empty($operation)) { + $operation = $this->guessOperationForColumn($name); + } + $operationForColumn[$name] = $operation; + } + return $operationForColumn; + } + + protected function aggregateDataArray(array $data, array $operationForColumn) + { + $results = array(); + foreach ($data as $row) { + if (!is_array($row)) { + // this is not a data array to aggregate + return $data; + } + foreach ($row as $name => $value) { + $operation = $operationForColumn[$name]; + switch ($operation) { + case 'sum': + if (!isset($results[$name])) { + $results[$name] = 0; + } + $results[$name] += $value; + break; + + case 'max': + if (!isset($results[$name])) { + $results[$name] = 0; + } + $results[$name] = max($results[$name], $value); + break; + + case 'min': + if (!isset($results[$name])) { + $results[$name] = $value; + } + $results[$name] = min($results[$name], $value); + break; + + case false: + // do nothing if the operation is not known (eg. nb_uniq_visitors should be not be aggregated) + break; + + default: + throw new Exception("Operation not applicable."); + break; + } + } + } + return $results; + } + + protected function defaultColumnsToZero($columns, $results) + { + foreach ($columns as $name) { + if (!isset($results[$name])) { + $results[$name] = 0; + } + } + return $results; + } + + protected function enrichWithUniqueVisitorsMetric(&$results) + { + if (array_key_exists('nb_uniq_visitors', $results)) { + if (SettingsPiwik::isUniqueVisitorsEnabled($this->getPeriod()->getLabel())) { + $results['nb_uniq_visitors'] = (float)$this->computeNbUniqVisitors(); + } else { + unset($results['nb_uniq_visitors']); + } + } + } + + protected function guessOperationForColumn($column) + { + if (strpos($column, 'max_') === 0) { + return 'max'; + } + if (strpos($column, 'min_') === 0) { + return 'min'; + } + if ($column === 'nb_uniq_visitors') { + return false; + } + return 'sum'; + } + + /** + * Processes number of unique visitors for the given period + * + * This is the only Period metric (ie. week/month/year/range) that we process from the logs directly, + * since unique visitors cannot be summed like other metrics. + * + * @return int + */ + protected function computeNbUniqVisitors() + { + $logAggregator = $this->getLogAggregator(); + $query = $logAggregator->queryVisitsByDimension(array(), false, array(), array(Metrics::INDEX_NB_UNIQ_VISITORS)); + $data = $query->fetch(); + return $data[Metrics::INDEX_NB_UNIQ_VISITORS]; + } +} diff --git a/core/ArchiveProcessor/Aggregator.php b/core/ArchiveProcessor/Aggregator.php deleted file mode 100644 index 3f8a437fa8..0000000000 --- a/core/ArchiveProcessor/Aggregator.php +++ /dev/null @@ -1,364 +0,0 @@ -<?php -/** - * Piwik - Open source web analytics - * - * @link http://piwik.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * - * @category Piwik - * @package Piwik - */ - -namespace Piwik\ArchiveProcessor; - -use Exception; -use Piwik\Archive; -use Piwik\ArchiveProcessor; -use Piwik\Common; -use Piwik\DataTable; -use Piwik\DataTable\Manager; -use Piwik\Metrics; -use Piwik\Piwik; -use Piwik\SettingsPiwik; - -/** - * Initiates the archiving process for group of days, eg. week period via the [ArchiveProcessor.aggregateMultipleReports](#) - * event. - * - * Period archiving differs from archiving day periods in that log tables are not aggregated. - * Instead the data from periods within the non-day period are aggregated. For example, if the data - * for a month is being archived, this ArchiveProcessor will select the aggregated data for each - * day in the month and add them together. This is much faster than running aggregation queries over - * the entire set of visits. - * - * If data has not been archived for the subperiods, archiving will be launched for those subperiods. - * - * ### Examples - * - * **Archiving metric data** - * - * // function in an Archiver descendent - * public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - * { - * $archiveProcessor->aggregateNumericMetrics('myFancyMetric', 'sum'); - * $archiveProcessor->aggregateNumericMetrics('myOtherFancyMetric', 'max'); - * } - * - * **Archiving report data** - * - * // function in an Archiver descendent - * public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - * { - * $maxRowsInTable = Config::getInstance()->General['datatable_archiving_maximum_rows_standard'];j - * - * $archiveProcessor->aggregateDataTableRecords( - * 'MyPlugin_myFancyReport', - * $maxRowsInTable, - * $maxRowsInSubtable = $maxRowsInTable, - * $columnToSortByBeforeTruncation = Metrics::INDEX_NB_VISITS, - * ); - * } - * - * @package Piwik - * @subpackage ArchiveProcessor - * - * @api - */ -class Aggregator extends ArchiveProcessor -{ - /** - * Array of (column name before => column name renamed) of the columns for which sum operation is invalid. - * These columns will be renamed as per this mapping. - * @var array - */ - protected static $invalidSummedColumnNameToRenamedName = array( - Metrics::INDEX_NB_UNIQ_VISITORS => Metrics::INDEX_SUM_DAILY_NB_UNIQ_VISITORS - ); - - /** - * @var Archive - */ - protected $archiver = null; - - /** - * Sums records for every subperiod of the current period and inserts the result as the record - * for this period. - * - * DataTables are summed recursively so subtables will be summed as well. - * - * @param string|array $recordNames Name(s) of the report we are aggregating, eg, `'Referrers_type'`. - * @param int $maximumRowsInDataTableLevelZero Maximum number of rows allowed in the top level DataTable. - * @param int $maximumRowsInSubDataTable Maximum number of rows allowed in each subtable. - * @param string $columnToSortByBeforeTruncation The name of the column to sort by before truncating a DataTable. - * @param array $columnAggregationOperations Operations for aggregating columns, @see Row::sumRow(). - * @param array $invalidSummedColumnNameToRenamedName For columns that must change names when summed because they - * cannot be summed, eg, - * `array('nb_uniq_visitors' => 'sum_daily_nb_uniq_visitors')`. - * @return array Returns the row counts of each aggregated report before truncation, eg, - * ``` - * array( - * 'report1' => array('level0' => $report1->getRowsCount, - * 'recursive' => $report1->getRowsCountRecursive()), - * 'report2' => array('level0' => $report2->getRowsCount, - * 'recursive' => $report2->getRowsCountRecursive()), - * ... - * ) - * ``` - */ - public function aggregateDataTableRecords($recordNames, - $maximumRowsInDataTableLevelZero = null, - $maximumRowsInSubDataTable = null, - $columnToSortByBeforeTruncation = null, - &$columnAggregationOperations = null, - $invalidSummedColumnNameToRenamedName = null) - { - // We clean up below all tables created during this function call (and recursive calls) - $latestUsedTableId = Manager::getInstance()->getMostRecentTableId(); - if (!is_array($recordNames)) { - $recordNames = array($recordNames); - } - $this->initArchiver(); - $nameToCount = array(); - foreach ($recordNames as $recordName) { - $table = $this->getRecordDataTableSum($recordName, $invalidSummedColumnNameToRenamedName, $columnAggregationOperations); - - $nameToCount[$recordName]['level0'] = $table->getRowsCount(); - $nameToCount[$recordName]['recursive'] = $table->getRowsCountRecursive(); - - $blob = $table->getSerialized($maximumRowsInDataTableLevelZero, $maximumRowsInSubDataTable, $columnToSortByBeforeTruncation); - Common::destroy($table); - $this->insertBlobRecord($recordName, $blob); - } - Manager::getInstance()->deleteAll($latestUsedTableId); - - return $nameToCount; - } - - /** - * Aggregates metrics for every subperiod of the current period and inserts the result - * as the metric for this period. - * - * @param array|string $columns Array of metric names to aggregate. - * @param bool|string $operationToApply The operation to apply to the metric. Either `'sum'`, `'max'` or `'min'`. - * @return array|int Returns the array of aggregate values. If only one metric was aggregated, - * the aggregate value will be returned as is, not in an array. - * For example, if `array('nb_visits', 'nb_hits')` is supplied for `$columns`, - * ``` - * array( - * 'nb_visits' => 3040, - * 'nb_hits' => 405 - * ) - * ``` - * is returned. - */ - public function aggregateNumericMetrics($columns, $operationToApply = false) - { - if (!is_array($columns)) { - $columns = array($columns); - } - $this->initArchiver(); - $data = $this->archiver->getNumeric($columns); - $operationForColumn = $this->getOperationForColumns($columns, $operationToApply); - $results = $this->aggregateDataArray($data, $operationForColumn); - $results = $this->defaultColumnsToZero($columns, $results); - $this->enrichWithUniqueVisitorsMetric($results); - - foreach ($results as $name => $value) { - $this->archiveWriter->insertRecord($name, $value); - } - - // if asked for only one field to sum - if (count($results) == 1) { - return reset($results); - } - - // returns the array of records once summed - return $results; - } - - protected function initArchiver() - { - if (empty($this->archiver)) { - $subPeriods = $this->getPeriod()->getSubperiods(); - $this->archiver = Archive::factory($this->getSegment(), $subPeriods, array($this->getSite()->getId())); - } - } - - /** - * This method selects all DataTables that have the name $name over the period. - * All these DataTables are then added together, and the resulting DataTable is returned. - * - * @param string $name - * @param array $invalidSummedColumnNameToRenamedName columns in the array (old name, new name) to be renamed as the sum operation is not valid on them (eg. nb_uniq_visitors->sum_daily_nb_uniq_visitors) - * @param array $columnAggregationOperations Operations for aggregating columns, @see Row::sumRow() - * @return DataTable - */ - protected function getRecordDataTableSum($name, $invalidSummedColumnNameToRenamedName, $columnAggregationOperations = null) - { - $table = new DataTable(); - if (!empty($columnAggregationOperations)) { - $table->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnAggregationOperations); - } - - $data = $this->archiver->getDataTableExpanded($name, $idSubTable = null, $depth = null, $addMetadataSubtableId = false); - if ($data instanceof DataTable\Map) { - foreach ($data->getDataTables() as $date => $tableToSum) { - $table->addDataTable($tableToSum); - } - } else { - $table->addDataTable($data); - } - - if (is_null($invalidSummedColumnNameToRenamedName)) { - $invalidSummedColumnNameToRenamedName = self::$invalidSummedColumnNameToRenamedName; - } - foreach ($invalidSummedColumnNameToRenamedName as $oldName => $newName) { - $table->renameColumn($oldName, $newName); - } - return $table; - } - - protected function compute() - { - /** - * Triggered when the archiving process is initiated for a non-day period. - * - * Plugins that compute analytics data should subscribe to this event. The - * actual archiving logic, however, should not be in the event handler, but - * in a class that descends from [Archiver](#). - * - * To learn more about non-day period archiving, see the [ArchiveProcessor\Aggregator](#) - * class. - * - * **Example** - * - * public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - * { - * $archiving = new MyArchiver($archiveProcessor); - * if ($archiving->shouldArchive()) { - * $archiving->aggregateMultipleReports(); - * } - * } - * - * @param \Piwik\ArchiveProcessor\Aggregator $archiveProcessor - * The ArchiveProcessor that triggered the event. - */ - Piwik::postEvent('ArchiveProcessor.aggregateMultipleReports', array(&$this)); - } - - protected function aggregateCoreVisitsMetrics() - { - $toSum = Metrics::getVisitsMetricNames(); - $metrics = $this->aggregateNumericMetrics($toSum); - return $metrics; - } - - protected function getOperationForColumns($columns, $defaultOperation) - { - $operationForColumn = array(); - foreach ($columns as $name) { - $operation = $defaultOperation; - if (empty($operation)) { - $operation = $this->guessOperationForColumn($name); - } - $operationForColumn[$name] = $operation; - } - return $operationForColumn; - } - - protected function aggregateDataArray(array $data, array $operationForColumn) - { - $results = array(); - foreach ($data as $row) { - if (!is_array($row)) { - // this is not a data array to aggregate - return $data; - } - foreach ($row as $name => $value) { - $operation = $operationForColumn[$name]; - switch ($operation) { - case 'sum': - if (!isset($results[$name])) { - $results[$name] = 0; - } - $results[$name] += $value; - break; - - case 'max': - if (!isset($results[$name])) { - $results[$name] = 0; - } - $results[$name] = max($results[$name], $value); - break; - - case 'min': - if (!isset($results[$name])) { - $results[$name] = $value; - } - $results[$name] = min($results[$name], $value); - break; - - case false: - // do nothing if the operation is not known (eg. nb_uniq_visitors should be not be aggregated) - break; - - default: - throw new Exception("Operation not applicable."); - break; - } - } - } - return $results; - } - - protected function defaultColumnsToZero($columns, $results) - { - foreach ($columns as $name) { - if (!isset($results[$name])) { - $results[$name] = 0; - } - } - return $results; - } - - protected function enrichWithUniqueVisitorsMetric(&$results) - { - if (array_key_exists('nb_uniq_visitors', $results)) { - if (SettingsPiwik::isUniqueVisitorsEnabled($this->getPeriod()->getLabel())) { - $results['nb_uniq_visitors'] = (float)$this->computeNbUniqVisitors(); - } else { - unset($results['nb_uniq_visitors']); - } - } - } - - protected function guessOperationForColumn($column) - { - if (strpos($column, 'max_') === 0) { - return 'max'; - } - if (strpos($column, 'min_') === 0) { - return 'min'; - } - if ($column === 'nb_uniq_visitors') { - return false; - } - return 'sum'; - } - - /** - * Processes number of unique visitors for the given period - * - * This is the only Period metric (ie. week/month/year/range) that we process from the logs directly, - * since unique visitors cannot be summed like other metrics. - * - * @return int - */ - protected function computeNbUniqVisitors() - { - $logAggregator = $this->getLogAggregator(); - $query = $logAggregator->queryVisitsByDimension(array(), false, array(), array(Metrics::INDEX_NB_UNIQ_VISITORS)); - $data = $query->fetch(); - return $data[Metrics::INDEX_NB_UNIQ_VISITORS]; - } -}
\ No newline at end of file diff --git a/core/ArchiveProcessor/Day.php b/core/ArchiveProcessor/Day.php deleted file mode 100644 index b359cfeea5..0000000000 --- a/core/ArchiveProcessor/Day.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Piwik - Open source web analytics - * - * @link http://piwik.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * - * @category Piwik - * @package Piwik - */ -namespace Piwik\ArchiveProcessor; - -use Piwik\ArchiveProcessor; -use Piwik\DataArray; -use Piwik\DataTable; -use Piwik\Metrics; -use Piwik\Piwik; - -/** - * Initiates the archiving process for **day** periods via the [ArchiveProcessor.Day.compute](#) - * event. - * - * @package Piwik - * @subpackage ArchiveProcessor - * - * @api - */ -class Day extends ArchiveProcessor -{ - protected function aggregateCoreVisitsMetrics() - { - $query = $this->getLogAggregator()->queryVisitsByDimension(); - $data = $query->fetch(); - - $metrics = $this->convertMetricsIdToName($data); - $this->insertNumericRecords($metrics); - return $metrics; - } - - protected function convertMetricsIdToName($data) - { - $metrics = array(); - foreach ($data as $metricId => $value) { - $readableMetric = Metrics::$mappingFromIdToName[$metricId]; - $metrics[$readableMetric] = $value; - } - return $metrics; - } - - protected function compute() - { - /** - * Triggered when the archiving process is initiated for a day period. - * - * Plugins that compute analytics data should subscribe to this event. The - * actual archiving logic, however, should not be in the event handler, but - * in a class that descends from [Archiver](#). - * - * To learn more about single day archiving, see the [ArchiveProcessor\Day](#) - * class. - * - * **Example** - * - * public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - * { - * $archiving = new MyArchiver($archiveProcessor); - * if ($archiving->shouldArchive()) { - * $archiving->aggregateDayReport(); - * } - * } - * - * @param \Piwik\ArchiveProcessor\Day $archiveProcessor - * The ArchiveProcessor that triggered the event. - */ - Piwik::postEvent('ArchiveProcessor.aggregateDayReport', array(&$this)); - } -}
\ No newline at end of file diff --git a/core/Plugin/Archiver.php b/core/Plugin/Archiver.php index 9710b619d2..21ab1fed4d 100644 --- a/core/Plugin/Archiver.php +++ b/core/Plugin/Archiver.php @@ -44,26 +44,6 @@ use Piwik\Config as PiwikConfig; * } * } * - * **Using Archiver in archiving events** - * - * // event observer for ArchiveProcessor.Day.compute - * public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - * { - * $archiving = new Archiver($archiveProcessor); - * if ($archiving->shouldArchive()) { - * $archiving->aggregateDayReport(); - * } - * } - * - * // event observer for ArchiveProcessor.aggregateMultipleReports - * public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - * { - * $archiving = new Archiver($archiveProcessor); - * if ($archiving->shouldArchive()) { - * $archiving->aggregateMultipleReports(); - * } - * } - * * @api */ abstract class Archiver @@ -83,7 +63,9 @@ abstract class Archiver } /** - * Archive data for a day period. + * Triggered when the archiving process is initiated for a day period. + * + * Plugins that compute analytics data should create an Archiver class that descends from [Plugin\Archiver](#). */ abstract public function aggregateDayReport(); @@ -109,7 +91,7 @@ abstract class Archiver } /** - * @return \Piwik\ArchiveProcessor\Day|\Piwik\ArchiveProcessor\Aggregator + * @return \Piwik\ArchiveProcessor */ protected function getProcessor() { diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index f5b1c0b068..4c7979bd73 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -27,7 +27,7 @@ require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php'; /** * The singleton that manages plugin loading/unloading and installation/uninstallation. * - * @static \Piwik\Plugin\Manager getInstance() + * @method static \Piwik\Plugin\Manager getInstance() * @package Piwik * @subpackage Manager */ diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index 58d2d3430c..4580950c40 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -39,8 +39,6 @@ class Actions extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'WidgetsList.addWidgets' => 'addWidgets', 'Menu.Reporting.addItems' => 'addMenus', 'API.getReportMetadata' => 'getReportMetadata', @@ -506,28 +504,6 @@ class Actions extends \Piwik\Plugin return Site::isSiteSearchEnabledFor($idSite); } - /** - * Compute all the actions along with their hierarchies. - * - * For each action we process the "interest statistics" : - * visits, unique visitors, bounce count, sum visit length. - */ - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - - function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - static public function checkCustomVariablesPluginEnabled() { if (!self::isCustomVariablesPluginsEnabled()) { diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php index 1cddd23187..f11ea3963a 100644 --- a/plugins/Actions/Archiver.php +++ b/plugins/Actions/Archiver.php @@ -10,7 +10,6 @@ */ namespace Piwik\Plugins\Actions; -use Piwik\ArchiveProcessor\Aggregator; use Piwik\DataTable; use Piwik\Metrics; use Piwik\RankingQuery; diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php index 0c6ad4f9ff..f87fc6bfd9 100644 --- a/plugins/CustomVariables/CustomVariables.php +++ b/plugins/CustomVariables/CustomVariables.php @@ -35,8 +35,6 @@ class CustomVariables extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'WidgetsList.addWidgets' => 'addWidgets', 'Menu.Reporting.addItems' => 'addMenus', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', @@ -134,25 +132,6 @@ class CustomVariables extends \Piwik\Plugin ); } - /** - * Hooks on daily archive to trigger various log processing - */ - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - public function configureViewDataTable(ViewDataTable $view) { switch ($view->requestConfig->apiMethodToRequestDataTable) { diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index 868433446f..22674d13f8 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -91,8 +91,6 @@ class DevicesDetection extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'Menu.Reporting.addItems' => 'addMenu', 'Tracker.newVisitorInformation' => 'parseMobileVisitData', 'WidgetsList.addWidgets' => 'addWidgets', @@ -272,22 +270,6 @@ class DevicesDetection extends \Piwik\Plugin Common::printDebug($deviceInfo); } - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - public function addMenu() { MenuMain::getInstance()->add('General_Visitors', 'DevicesDetection_submenu', array('module' => 'DevicesDetection', 'action' => 'index')); diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 21e78b99d1..ace61a9478 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -92,8 +92,6 @@ class Goals extends \Piwik\Plugin 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'Site.getSiteAttributes' => 'fetchGoalsFromDb', - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'API.getReportMetadata.end' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', 'WidgetsList.addWidgets' => 'addWidgets', @@ -507,28 +505,6 @@ class Goals extends \Piwik\Plugin return $site->isEcommerceEnabled() ? 'Goals_EcommerceAndGoalsMenu' : 'Goals_Goals'; } - /** - */ - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - - /** - * Hooks on Period archiving. - * Sums up Goal conversions stats, and processes overall conversion rate - */ - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - public function configureViewDataTable(ViewDataTable $view) { switch ($view->requestConfig->apiMethodToRequestDataTable) { diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 960cbc974b..7ff9b696a0 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -35,8 +35,6 @@ class Provider extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'Tracker.newVisitorInformation' => 'enrichVisitWithProviderInfo', 'WidgetsList.addWidgets' => 'addWidget', 'Menu.Reporting.addItems' => 'addMenu', @@ -220,25 +218,6 @@ class Provider extends \Piwik\Plugin $out .= '</div>'; } - /** - * Daily archive: processes the report Visits by Provider - */ - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - public function configureViewDataTable(ViewDataTable $view) { switch ($view->requestConfig->apiMethodToRequestDataTable) { diff --git a/plugins/Referrers/Referrers.php b/plugins/Referrers/Referrers.php index 8036650374..463187c92d 100644 --- a/plugins/Referrers/Referrers.php +++ b/plugins/Referrers/Referrers.php @@ -37,8 +37,6 @@ class Referrers extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'WidgetsList.addWidgets' => 'addWidgets', 'Menu.Reporting.addItems' => 'addMenus', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', @@ -277,29 +275,6 @@ class Referrers extends \Piwik\Plugin )); } - /** - * Hooks on daily archive to trigger various log processing - */ - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - - /** - * Period archiving: sums up daily stats and sums report tables, - * making sure that tables are still truncated. - */ - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - public function getDefaultTypeViewDataTable(&$defaultViewTypes) { $defaultViewTypes['Referrers.getReferrerType'] = AllColumns::ID; diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php index c41764ac81..b6e66cb8e9 100644 --- a/plugins/Transitions/API.php +++ b/plugins/Transitions/API.php @@ -76,7 +76,7 @@ class API extends \Piwik\Plugin\API $segment = new Segment($segment, $idSite); $site = new Site($idSite); $period = Period::factory($period, $date); - $archiveProcessor = new ArchiveProcessor\Day($period, $site, $segment); + $archiveProcessor = new ArchiveProcessor($period, $site, $segment); $logAggregator = $archiveProcessor->getLogAggregator(); // prepare the report $report = array( diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 68407a66c8..3478e1aac2 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -42,8 +42,6 @@ class UserCountry extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'WidgetsList.addWidgets' => 'addWidgets', 'Menu.Reporting.addItems' => 'addMenu', 'Menu.Admin.addItems' => 'addAdminMenu', @@ -329,22 +327,6 @@ class UserCountry extends \Piwik\Plugin )); } - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - /** * Returns a list of country codes for a given continent code. * diff --git a/plugins/UserSettings/Archiver.php b/plugins/UserSettings/Archiver.php index bc38a1dec7..3b490dd7e1 100644 --- a/plugins/UserSettings/Archiver.php +++ b/plugins/UserSettings/Archiver.php @@ -41,6 +41,11 @@ class Archiver extends \Piwik\Plugin\Archiver const OS_DIMENSION = "log_visit.config_os"; const CONFIGURATION_DIMENSION = "CONCAT(log_visit.config_os, ';', log_visit.config_browser_name, ';', log_visit.config_resolution)"; + /** + * Daily archive of User Settings report. Processes reports for Visits by Resolution, + * by Browser, Browser family, etc. Some reports are built from the logs, some reports + * are superset of an existing report (eg. Browser family is built from the Browser report) + */ public function aggregateDayReport() { $this->aggregateByConfiguration(); @@ -146,6 +151,9 @@ class Archiver extends \Piwik\Plugin\Archiver return $this->getProcessor()->insertBlobRecord($recordName, $report); } + /** + * Period archiving: simply sums up daily archives + */ public function aggregateMultipleReports() { $dataTableRecords = array( diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index 1764b317ae..bfb73aecfa 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -169,8 +169,6 @@ class UserSettings extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'WidgetsList.addWidgets' => 'addWidgets', 'Menu.Reporting.addItems' => 'addMenu', 'API.getReportMetadata' => 'getReportMetadata', @@ -468,27 +466,4 @@ class UserSettings extends \Piwik\Plugin MenuMain::getInstance()->add('General_Visitors', 'General_Settings', array('module' => 'UserSettings', 'action' => 'index')); } - /** - * Daily archive of User Settings report. Processes reports for Visits by Resolution, - * by Browser, Browser family, etc. Some reports are built from the logs, some reports - * are superset of an existing report (eg. Browser family is built from the Browser report) - */ - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - - /** - * Period archiving: simply sums up daily archives - */ - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } }
\ No newline at end of file diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index fda9830a27..7176ed7ae0 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -35,8 +35,6 @@ class VisitTime extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'WidgetsList.addWidgets' => 'addWidgets', 'Menu.Reporting.addItems' => 'addMenu', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', @@ -196,22 +194,6 @@ class VisitTime extends \Piwik\Plugin } } - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - private static function getDateRangeForFooterMessage() { // get query params diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index 4a3288d35e..dd3c83aaa4 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -33,8 +33,6 @@ class VisitorInterest extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'ArchiveProcessor.aggregateDayReport' => 'aggregateDayReport', - 'ArchiveProcessor.aggregateMultipleReports' => 'aggregateMultipleReports', 'WidgetsList.addWidgets' => 'addWidgets', 'Menu.Reporting.addItems' => 'addMenu', 'API.getReportMetadata' => 'getReportMetadata', @@ -125,22 +123,6 @@ class VisitorInterest extends \Piwik\Plugin Piwik::addAction('Template.footerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\VisitorInterest', 'footerVisitsFrequency')); } - public function aggregateMultipleReports(ArchiveProcessor\Aggregator $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateMultipleReports(); - } - } - - public function aggregateDayReport(ArchiveProcessor\Day $archiveProcessor) - { - $archiving = new Archiver($archiveProcessor); - if ($archiving->shouldArchive()) { - $archiving->aggregateDayReport(); - } - } - static public function headerVisitsFrequency(&$out) { $out = '<div id="leftcolumn">'; diff --git a/tests/PHPUnit/Core/ArchiveProcessingTest.php b/tests/PHPUnit/Core/ArchiveProcessingTest.php index fb4d924d61..e1bb90adb0 100644 --- a/tests/PHPUnit/Core/ArchiveProcessingTest.php +++ b/tests/PHPUnit/Core/ArchiveProcessingTest.php @@ -70,12 +70,7 @@ class ArchiveProcessingTest extends DatabaseTestCase $period = Period::factory($periodLabel, $date); $segment = new Segment('', $site->getId()); - - if($period->getLabel() == 'day') { - return new ArchiveProcessor\Day($period, $site, $segment); - } else { - return new ArchiveProcessor\Aggregator($period, $site, $segment); - } + return new ArchiveProcessor($period, $site, $segment); } /** |