diff options
Diffstat (limited to 'core/ArchiveProcessor')
-rw-r--r-- | core/ArchiveProcessor/Day.php | 14 | ||||
-rw-r--r-- | core/ArchiveProcessor/Period.php | 26 | ||||
-rw-r--r-- | core/ArchiveProcessor/Rules.php | 26 |
3 files changed, 41 insertions, 25 deletions
diff --git a/core/ArchiveProcessor/Day.php b/core/ArchiveProcessor/Day.php index 8d17b34ad2..ba8fbb3ae6 100644 --- a/core/ArchiveProcessor/Day.php +++ b/core/ArchiveProcessor/Day.php @@ -8,19 +8,23 @@ * @category Piwik * @package Piwik */ +namespace Piwik\ArchiveProcessor; use Piwik\Metrics; +use Piwik\ArchiveProcessor; +use Piwik_DataArray; +use Piwik\DataTable; /** * This class * @package Piwik - * @subpackage Piwik_ArchiveProcessor + * @subpackage ArchiveProcessor */ -class Piwik_ArchiveProcessor_Day extends Piwik_ArchiveProcessor +class Day extends ArchiveProcessor { /** * Converts the given array to a datatable * @param Piwik_DataArray $array - * @return Piwik_DataTable + * @return \Piwik\DataTable */ static public function getDataTableFromDataArray(Piwik_DataArray $array) { @@ -31,10 +35,10 @@ class Piwik_ArchiveProcessor_Day extends Piwik_ArchiveProcessor if (!empty($dataArrayTwoLevels)) { $subtableByLabel = array(); foreach ($dataArrayTwoLevels as $label => $subTable) { - $subtableByLabel[$label] = Piwik_DataTable::makeFromIndexedArray($subTable); + $subtableByLabel[$label] = DataTable::makeFromIndexedArray($subTable); } } - return Piwik_DataTable::makeFromIndexedArray($dataArray, $subtableByLabel); + return DataTable::makeFromIndexedArray($dataArray, $subtableByLabel); } /** diff --git a/core/ArchiveProcessor/Period.php b/core/ArchiveProcessor/Period.php index 0350adb034..6f7085c1a9 100644 --- a/core/ArchiveProcessor/Period.php +++ b/core/ArchiveProcessor/Period.php @@ -8,10 +8,18 @@ * @category Piwik * @package Piwik */ + +namespace Piwik\ArchiveProcessor; + +use Exception; use Piwik\Archive; use Piwik\Metrics; use Piwik\Piwik; use Piwik\Common; +use Piwik\ArchiveProcessor; +use Piwik\DataTable; +use Piwik\DataTable\Map; +use Piwik\DataTable\Manager; /** * This class provides generic methods to archive data for a period (week / month / year). @@ -21,9 +29,9 @@ use Piwik\Common; * Public methods can be called by the plugins that hook on the event 'ArchiveProcessing_Period.compute' * * @package Piwik - * @subpackage Piwik_ArchiveProcessor + * @subpackage ArchiveProcessor */ -class Piwik_ArchiveProcessor_Period extends Piwik_ArchiveProcessor +class Period extends ArchiveProcessor { /** * Array of (column name before => column name renamed) of the columns for which sum operation is invalid. @@ -58,7 +66,7 @@ class Piwik_ArchiveProcessor_Period extends Piwik_ArchiveProcessor * @param int $maximumRowsInDataTableLevelZero Max row count of parent datatable to archive * @param int $maximumRowsInSubDataTable Max row count of children datatable(s) to archive * @param string $columnToSortByBeforeTruncation Column name to sort by, before truncating rows (ie. if there are more rows than the specified max row count) - * @param array $columnAggregationOperations Operations for aggregating columns, @see Piwik_DataTable_Row::sumRow() + * @param array $columnAggregationOperations Operations for aggregating columns, @see Row::sumRow() * @param array $invalidSummedColumnNameToRenamedName (current_column_name => new_column_name) for columns that must change names when summed * (eg. unique visitors go from nb_uniq_visitors to sum_daily_nb_uniq_visitors) * @@ -75,7 +83,7 @@ class Piwik_ArchiveProcessor_Period extends Piwik_ArchiveProcessor $invalidSummedColumnNameToRenamedName = null) { // We clean up below all tables created during this function call (and recursive calls) - $latestUsedTableId = Piwik_DataTable_Manager::getInstance()->getMostRecentTableId(); + $latestUsedTableId = Manager::getInstance()->getMostRecentTableId(); if (!is_array($recordNames)) { $recordNames = array($recordNames); } @@ -91,7 +99,7 @@ class Piwik_ArchiveProcessor_Period extends Piwik_ArchiveProcessor Common::destroy($table); $this->insertBlobRecord($recordName, $blob); } - Piwik_DataTable_Manager::getInstance()->deleteAll($latestUsedTableId); + Manager::getInstance()->deleteAll($latestUsedTableId); return $nameToCount; } @@ -147,18 +155,18 @@ class Piwik_ArchiveProcessor_Period extends Piwik_ArchiveProcessor * * @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 Piwik_DataTable_Row::sumRow() - * @return Piwik_DataTable + * @param array $columnAggregationOperations Operations for aggregating columns, @see Row::sumRow() + * @return DataTable */ protected function getRecordDataTableSum($name, $invalidSummedColumnNameToRenamedName, $columnAggregationOperations = null) { - $table = new Piwik_DataTable(); + $table = new DataTable(); if (!empty($columnAggregationOperations)) { $table->setColumnAggregationOperations($columnAggregationOperations); } $data = $this->archiver->getDataTableExpanded($name, $idSubTable = null, $addMetadataSubtableId = false); - if ($data instanceof Piwik_DataTable_Array) { + if ($data instanceof DataTable\Map) { foreach ($data->getArray() as $date => $tableToSum) { $table->addDataTable($tableToSum); } diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php index de856f470b..d58c7e5fb3 100644 --- a/core/ArchiveProcessor/Rules.php +++ b/core/ArchiveProcessor/Rules.php @@ -8,17 +8,21 @@ * @category Piwik * @package Piwik */ +namespace Piwik\ArchiveProcessor; + +use Exception; use Piwik\Config; -use Piwik\Period; use Piwik\Piwik; use Piwik\Common; use Piwik\Segment; use Piwik\Site; +use Piwik\Date; +use Piwik_Tracker_Cache; /** * This class contains Archiving rules/logic which are used in several places */ -class Piwik_ArchiveProcessor_Rules +class Rules { const OPTION_TODAY_ARCHIVE_TTL = 'todayArchiveTimeToLive'; @@ -98,10 +102,10 @@ class Piwik_ArchiveProcessor_Rules * Given a monthly archive table, will delete all reports that are now outdated, * or reports that ended with an error * - * @param Piwik_Date $date + * @param \Piwik\Date $date * @return int|bool False, or timestamp indicating which archives to delete */ - public static function shouldPurgeOutdatedArchives(Piwik_Date $date) + public static function shouldPurgeOutdatedArchives(Date $date) { if (self::$purgeDisabledByTests) { return false; @@ -128,10 +132,10 @@ class Piwik_ArchiveProcessor_Rules if (self::isBrowserTriggerEnabled()) { // If Browser Archiving is enabled, it is likely there are many more temporary archives // We delete more often which is safe, since reports are re-processed on demand - $purgeArchivesOlderThan = Piwik_Date::factory(time() - 2 * $temporaryArchivingTimeout)->getDateTime(); + $purgeArchivesOlderThan = Date::factory(time() - 2 * $temporaryArchivingTimeout)->getDateTime(); } else { // If archive.php via Cron is building the reports, we should keep all temporary reports from today - $purgeArchivesOlderThan = Piwik_Date::factory('today')->getDateTime(); + $purgeArchivesOlderThan = Date::factory('today')->getDateTime(); } return $purgeArchivesOlderThan; } @@ -140,12 +144,12 @@ class Piwik_ArchiveProcessor_Rules return false; } - public static function getMinTimeProcessedForTemporaryArchive(Piwik_Date $dateStart, Period $period, Segment $segment, Site $site) + public static function getMinTimeProcessedForTemporaryArchive(Date $dateStart, \Piwik\Period $period, Segment $segment, Site $site) { $now = time(); - $minimumArchiveTime = $now - Piwik_ArchiveProcessor_Rules::getTodayArchiveTimeToLive(); + $minimumArchiveTime = $now - Rules::getTodayArchiveTimeToLive(); - $isArchivingDisabled = Piwik_ArchiveProcessor_Rules::isArchivingDisabledFor($segment, $period->getLabel()); + $isArchivingDisabled = Rules::isArchivingDisabledFor($segment, $period->getLabel()); if ($isArchivingDisabled) { if ($period->getNumberOfSubperiods() == 0 && $dateStart->getTimestamp() <= $now @@ -156,7 +160,7 @@ class Piwik_ArchiveProcessor_Rules // This week, this month, this year: // accept any archive that was processed today after 00:00:01 this morning $timezone = $site->getTimezone(); - $minimumArchiveTime = Piwik_Date::factory(Piwik_Date::factory('now', $timezone)->getDateStartUTC())->setTimezone($timezone)->getTimestamp(); + $minimumArchiveTime = Date::factory(Date::factory('now', $timezone)->getDateStartUTC())->setTimezone($timezone)->getTimestamp(); } } return $minimumArchiveTime; @@ -207,7 +211,7 @@ class Piwik_ArchiveProcessor_Rules protected static function isRequestAuthorizedToArchive() { return !self::$archivingDisabledByTests && - (Piwik_ArchiveProcessor_Rules::isBrowserTriggerEnabled() + (Rules::isBrowserTriggerEnabled() || Common::isPhpCliMode() || (Piwik::isUserIsSuperUser() && Common::isArchivePhpTriggered())); |