diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-06-05 07:57:44 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-06-05 07:57:44 +0400 |
commit | e48c41ceebc371d6b2926fb6f1d2d4e2a0823d82 (patch) | |
tree | f1d96e0cee025c18300b2ae1ce2393177b5ca3bf /plugins/CustomVariables | |
parent | 0e24430df2d4df266982524d6d5f56252ed180e4 (diff) |
Factoring out archiving Custom variables + cleaning it up (breaking down huge archiveDay function into several methods)
Renaming some core code to make sense (sumMetrics and makeEmptyRow instead of ugly names)
TODO: continue with other plugins
Diffstat (limited to 'plugins/CustomVariables')
-rw-r--r-- | plugins/CustomVariables/API.php | 16 | ||||
-rw-r--r-- | plugins/CustomVariables/Archiving.php | 230 | ||||
-rw-r--r-- | plugins/CustomVariables/Controller.php | 29 | ||||
-rw-r--r-- | plugins/CustomVariables/CustomVariables.php | 171 |
4 files changed, 267 insertions, 179 deletions
diff --git a/plugins/CustomVariables/API.php b/plugins/CustomVariables/API.php index 3a47c837c5..282406e679 100644 --- a/plugins/CustomVariables/API.php +++ b/plugins/CustomVariables/API.php @@ -42,8 +42,9 @@ class Piwik_CustomVariables_API protected function getDataTable($idSite, $period, $date, $segment, $expanded, $idSubtable) { $dataTable = Piwik_Archive::getDataTableFromArchive('CustomVariables_valueByName', $idSite, $period, $date, $segment, $expanded, $idSubtable); - $dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS, 'desc', $naturalSort = false, $expanded)); + $dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_ACTIONS, 'desc', $naturalSort = false, $expanded)); $dataTable->queueFilter('ReplaceColumnNames'); + $dataTable->queueFilter('ColumnDelete', 'nb_uniq_visitors'); return $dataTable; } @@ -64,7 +65,7 @@ class Piwik_CustomVariables_API if ($dataTable instanceof Piwik_DataTable && !$_leavePiwikCoreVariables ) { - $mapping = array('_pks', '_pkn', '_pkc', '_pkp', Piwik_Tracker_Action::CVAR_KEY_SEARCH_COUNT, Piwik_Tracker_Action::CVAR_KEY_SEARCH_CATEGORY); + $mapping = self::getReservedCustomVariableKeys(); foreach ($mapping as $name) { $row = $dataTable->getRowFromLabel($name); if ($row) { @@ -76,6 +77,15 @@ class Piwik_CustomVariables_API } /** + * @ignore + * @return array + */ + public static function getReservedCustomVariableKeys() + { + return array('_pks', '_pkn', '_pkc', '_pkp', Piwik_Tracker_Action::CVAR_KEY_SEARCH_COUNT, Piwik_Tracker_Action::CVAR_KEY_SEARCH_CATEGORY); + } + + /** * @param int $idSite * @param string $period * @param Piwik_Date $date @@ -96,7 +106,7 @@ class Piwik_CustomVariables_API $dataTable->renameColumn('price_viewed', 'price'); } $dataTable->queueFilter('ColumnCallbackReplace', array('label', create_function('$label', ' - return $label == Piwik_CustomVariables::LABEL_CUSTOM_VALUE_NOT_DEFINED + return $label == Piwik_CustomVariables_Archiving::LABEL_CUSTOM_VALUE_NOT_DEFINED ? "' . Piwik_Translate('General_NotDefined', Piwik_Translate('CustomVariables_ColumnCustomVariableValue')) . '" : $label;'))); return $dataTable; diff --git a/plugins/CustomVariables/Archiving.php b/plugins/CustomVariables/Archiving.php new file mode 100644 index 0000000000..e9ca547707 --- /dev/null +++ b/plugins/CustomVariables/Archiving.php @@ -0,0 +1,230 @@ +<?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_Plugins + * @package Piwik_CustomVariables + */ + +class Piwik_CustomVariables_Archiving +{ + const LABEL_CUSTOM_VALUE_NOT_DEFINED = "Value not defined"; + const BLOB_NAME = 'CustomVariables_valueByName'; + protected $metricsByKey = array(); + protected $metricsByKeyAndValue = array(); + protected $maximumRowsInDataTableLevelZero; + protected $maximumRowsInSubDataTable; + protected $newEmptyRow; + + function __construct() + { + //TODO FIX + $this->maximumRowsInDataTableLevelZero = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_referers']; + $this->maximumRowsInSubDataTable = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_referers']; + } + + public function archiveDay(Piwik_ArchiveProcessing_Day $archiveProcessing) + { + $this->archiveDayAggregate($archiveProcessing); + + $table = $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->metricsByKeyAndValue, $this->metricsByKey); + + + $blob = $table->getSerialized( + $this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, + $columnToSort = Piwik_Archive::INDEX_NB_VISITS + ); + + $archiveProcessing->insertBlobRecord(self::BLOB_NAME, $blob); + } + + /** + * @param Piwik_ArchiveProcessing_Day $archiveProcessing + * @return void + */ + protected function archiveDayAggregate(Piwik_ArchiveProcessing_Day $archiveProcessing) + { + for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { + $this->aggregateCustomVariable($archiveProcessing, $i); + } + + $this->removeVisitsMetricsFromActionsAggregate($archiveProcessing); + $archiveProcessing->enrichConversionsByLabelArray($this->metricsByKey); + $archiveProcessing->enrichConversionsByLabelArrayHasTwoLevels($this->metricsByKeyAndValue); + } + + /** + * @param Piwik_ArchiveProcessing_Day $archiveProcessing + * @param $slot + */ + protected function aggregateCustomVariable(Piwik_ArchiveProcessing_Day $archiveProcessing, $slot) + { + $keyField = "custom_var_k" . $slot; + $valueField = "custom_var_v" . $slot; + $where = "%s.$keyField != ''"; + $dimensions = array($keyField, $valueField); + + $query = $archiveProcessing->queryVisitsByDimension($dimensions, $where); + $this->aggregateFromVisits($archiveProcessing, $query, $keyField, $valueField); + + $query = $archiveProcessing->queryActionsByDimension($dimensions, $where); + $this->aggregateFromActions($archiveProcessing, $query, $keyField, $valueField); + + $query = $archiveProcessing->queryConversionsByDimension($dimensions, $where); + $this->aggregateFromConversions($archiveProcessing, $query, $keyField, $valueField); + } + + protected function aggregateFromVisits(Piwik_ArchiveProcessing_Day $archiveProcessing, $query, $keyField, $valueField) + { + while ($row = $query->fetch()) { + $value = $row[$valueField]; + $value = $this->cleanCustomVarValue($value); + + $key = $row[$keyField]; + if (!isset($this->metricsByKey[$key])) { + $this->metricsByKey[$key] = $archiveProcessing->makeEmptyRow(); + } + if (!isset($this->metricsByKeyAndValue[$key][$value])) { + $this->metricsByKeyAndValue[$key][$value] = $archiveProcessing->makeEmptyRow(); + } + + $archiveProcessing->sumMetrics($row, $this->metricsByKey[$key]); + $archiveProcessing->sumMetrics($row, $this->metricsByKeyAndValue[$key][$value]); + } + } + + protected function cleanCustomVarValue($value) + { + if (strlen($value)) { + return $value; + } + return self::LABEL_CUSTOM_VALUE_NOT_DEFINED; + } + + protected function aggregateFromActions(Piwik_ArchiveProcessing_Day $archiveProcessing, $query, $keyField, $valueField) + { + $keys = array(); + while ($row = $query->fetch()) { + $key = $row[$keyField]; + $value = $row[$valueField]; + $value = $this->cleanCustomVarValue($value); + + $alreadyAggregated = $this->aggregateEcommerceCategories($archiveProcessing, $key, $value, $row); + if (!$alreadyAggregated) { + $this->aggregateAction($archiveProcessing, $key, $value, $row); + + if (!isset($this->metricsByKey[$key])) { + $this->metricsByKey[$key] = $archiveProcessing->makeEmptyActionRow(); + } + $archiveProcessing->sumMetrics($row, $this->metricsByKey[$key], $onlyMetricsAvailableInActionsTable = true); + } + } + } + + /** + * @return bool True if the $row metrics were already added to the ->metrics + */ + protected function aggregateEcommerceCategories(Piwik_ArchiveProcessing_Day $archiveProcessing, $key, $value, $row) + { + $ecommerceCategoriesAggregated = false; + if ($key == '_pkc' + && $value[0] == '[' && $value[1] == '"' + ) { + // In case categories were truncated, try closing the array + if (substr($value, -2) != '"]') { + $value .= '"]'; + } + $decoded = @Piwik_Common::json_decode($value); + if (is_array($decoded)) { + $count = 0; + foreach ($decoded as $category) { + if (empty($category) + || $count >= Piwik_Tracker_GoalManager::MAXIMUM_PRODUCT_CATEGORIES + ) { + continue; + } + $this->aggregateAction($archiveProcessing, $key, $category, $row); + $ecommerceCategoriesAggregated = true; + $count++; + } + } + } + return $ecommerceCategoriesAggregated; + } + + /** + * @param Piwik_ArchiveProcessing_Day $archiveProcessing + * @param $key + * @param $value + * @param $row + */ + protected function aggregateAction(Piwik_ArchiveProcessing_Day $archiveProcessing, $key, $value, $row) + { + if (!isset($this->metricsByKeyAndValue[$key][$value])) { + $this->metricsByKeyAndValue[$key][$value] = $archiveProcessing->makeEmptyActionRow(); + } + $archiveProcessing->sumMetrics($row, $this->metricsByKeyAndValue[$key][$value], $onlyMetricsAvailableInActionsTable = true); + + if ($this->isReservedKey($key)) { + // Price tracking on Ecommerce product/category pages: + // The the AVG is returned from the SQL query so the price is not summed + $index = Piwik_Archive::INDEX_ECOMMERCE_ITEM_PRICE_VIEWED; + if (!empty($row[$index])) { + $this->metricsByKeyAndValue[$key][$value][$index] = (float)$row[$index]; + } + } + } + + protected static function isReservedKey($key) + { + return in_array($key, Piwik_CustomVariables_API::getReservedCustomVariableKeys()); + } + + protected function aggregateFromConversions(Piwik_ArchiveProcessing_Day $archiveProcessing, $query, $keyField, $valueField) + { + if ($query === false) { + return; + } + while ($row = $query->fetch()) { + $key = $row[$keyField]; + $value = $this->cleanCustomVarValue($row[$valueField]); + $idGoal = $row['idgoal']; + + if (!isset($this->metricsByKey[$key][Piwik_Archive::INDEX_GOALS][$idGoal])) { + $this->metricsByKey[$key][Piwik_Archive::INDEX_GOALS][$idGoal] = $archiveProcessing->makeEmptyGoalRow($idGoal); + } + if (!isset($this->metricsByKeyAndValue[$key][$value][Piwik_Archive::INDEX_GOALS][$idGoal])) { + $this->metricsByKeyAndValue[$key][$value][Piwik_Archive::INDEX_GOALS][$idGoal] = $archiveProcessing->makeEmptyGoalRow($idGoal); + } + + $archiveProcessing->sumGoalMetrics($row, $this->metricsByKey[$key][Piwik_Archive::INDEX_GOALS][$idGoal]); + $archiveProcessing->sumGoalMetrics($row, $this->metricsByKeyAndValue[$key][$value][Piwik_Archive::INDEX_GOALS][$idGoal]); + } + } + + protected function removeVisitsMetricsFromActionsAggregate(Piwik_ArchiveProcessing_Day $archiveProcessing) + { + $emptyActionRow = $archiveProcessing->makeEmptyActionRow(); + + foreach ($this->metricsByKey as $key => &$row) { + $isActionRowAggregate = (count($row) == count($emptyActionRow)); + if (!self::isReservedKey($key) + && $isActionRowAggregate + ) { + unset($row[Piwik_Archive::INDEX_NB_UNIQ_VISITORS]); + unset($row[Piwik_Archive::INDEX_NB_VISITS]); + } + } + } + + public function archivePeriod($archiveProcessing) + { + $nameToCount = $archiveProcessing->archiveDataTable( + self::BLOB_NAME, null, $this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, + $columnToSort = Piwik_Archive::INDEX_NB_VISITS); + } + +}
\ No newline at end of file diff --git a/plugins/CustomVariables/Controller.php b/plugins/CustomVariables/Controller.php index ea00259d3e..867988a79b 100644 --- a/plugins/CustomVariables/Controller.php +++ b/plugins/CustomVariables/Controller.php @@ -10,49 +10,52 @@ */ /** - * * @package Piwik_CustomVariables */ class Piwik_CustomVariables_Controller extends Piwik_Controller { - - function index($fetch = false) + public function index($fetch = false) { return Piwik_View::singleReport( Piwik_Translate('CustomVariables_CustomVariables'), $this->getCustomVariables(true), $fetch); } - function getCustomVariables($fetch = false) + public function getCustomVariables($fetch = false) { $view = Piwik_ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, "CustomVariables.getCustomVariables", "getCustomVariablesValuesFromNameId"); $this->setPeriodVariablesView($view); - $view->enableShowGoals(); + $this->setMetricsVariablesView($view); - $view->setColumnsToDisplay(array('label', 'nb_visits', 'nb_actions')); + $this->configureView($view); $view->setColumnTranslation('label', Piwik_Translate('CustomVariables_ColumnCustomVariableName')); - $view->setSortedColumn('nb_visits'); - $view->setLimit(10); + $view->setFooterMessage(Piwik_Translate('CustomVariables_TrackingHelp', array('<a target="_blank" href="http://piwik.org/docs/custom-variables/">', '</a>'))); - $this->setMetricsVariablesView($view); + return $this->renderView($view, $fetch); } - function getCustomVariablesValuesFromNameId($fetch = false) + public function getCustomVariablesValuesFromNameId($fetch = false) { $view = Piwik_ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'CustomVariables.getCustomVariablesValuesFromNameId'); + $this->configureView($view); $view->disableSearchBox(); - $view->enableShowGoals(); $view->disableExcludeLowPopulation(); - $view->setColumnsToDisplay(array('label', 'nb_visits', 'nb_actions')); $view->setColumnTranslation('label', Piwik_Translate('CustomVariables_ColumnCustomVariableValue')); - return $this->renderView($view, $fetch); } + protected function configureView($view) + { + $view->setColumnsToDisplay(array('label', 'nb_actions', 'nb_visits')); + $view->setSortedColumn('nb_actions'); + $view->enableShowGoals(); + } + + } diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php index d76adab5ea..1212f78cd9 100644 --- a/plugins/CustomVariables/CustomVariables.php +++ b/plugins/CustomVariables/CustomVariables.php @@ -14,11 +14,6 @@ */ class Piwik_CustomVariables extends Piwik_Plugin { - public $archiveProcessing; - protected $columnToSortByBeforeTruncation; - protected $maximumRowsInDataTableLevelZero; - protected $maximumRowsInSubDataTable; - public function getInformation() { $info = array( @@ -146,173 +141,24 @@ class Piwik_CustomVariables extends Piwik_Plugin )); } - function __construct() - { - $this->maximumRowsInDataTableLevelZero = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_referers']; - $this->maximumRowsInSubDataTable = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_referers']; - } - - protected $interestByCustomVariables = array(); - protected $interestByCustomVariablesAndValue = array(); - /** * Hooks on daily archive to trigger various log processing * * @param Piwik_Event_Notification $notification notification object - * @return void */ public function archiveDay($notification) { - $this->interestByCustomVariables = $this->interestByCustomVariablesAndValue = array(); - - /** - * @var Piwik_ArchiveProcessing_Day - */ - $this->archiveProcessing = $notification->getNotificationObject(); - - if (!$this->archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) return; - - $this->archiveDayAggregate($this->archiveProcessing); - $this->archiveDayRecordInDatabase($this->archiveProcessing); - destroy($this->interestByCustomVariables); - destroy($this->interestByCustomVariablesAndValue); - } - - const LABEL_CUSTOM_VALUE_NOT_DEFINED = "Value not defined"; - - /** - * @param Piwik_ArchiveProcessing_Day $archiveProcessing - * @return void - */ - protected function archiveDayAggregate(Piwik_ArchiveProcessing_Day $archiveProcessing) - { - for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { - $keyField = "custom_var_k" . $i; - $valueField = "custom_var_v" . $i; - $dimensions = array($keyField, $valueField); - $where = "%s.$keyField != ''"; - - // Custom Vars names and values metrics for visits - $query = $archiveProcessing->queryVisitsByDimension($dimensions, $where); - - while ($row = $query->fetch()) { - // Handle case custom var value is empty - $row[$valueField] = $this->cleanCustomVarValue($row[$valueField]); - - // Aggregate - if (!isset($this->interestByCustomVariables[$row[$keyField]])) $this->interestByCustomVariables[$row[$keyField]] = $archiveProcessing->getNewInterestRow(); - if (!isset($this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]])) $this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]] = $archiveProcessing->getNewInterestRow(); - $archiveProcessing->updateInterestStats($row, $this->interestByCustomVariables[$row[$keyField]]); - $archiveProcessing->updateInterestStats($row, $this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]]); - } - - // Custom Vars names and values metrics for page views - $query = $archiveProcessing->queryActionsByDimension($dimensions, $where); - $onlyMetricsAvailableInActionsTable = true; - while ($row = $query->fetch()) { - // Handle case custom var value is empty - $row[$valueField] = $this->cleanCustomVarValue($row[$valueField]); - - $label = $row[$valueField]; - - // Remove price tracked if it's zero or we if we are not currently tracking an ecommerce var - if (!in_array($row[$keyField], array('_pks', '_pkn', '_pkc'))) { - unset($row[Piwik_Archive::INDEX_ECOMMERCE_ITEM_PRICE_VIEWED]); - } - - // when custom variable value is a JSON array of categories - // possibly JSON value - $mustInsertCustomVariableValue = true; - if ($row[$keyField] == '_pkc' - && $label[0] == '[' && $label[1] == '"' - ) { - // In case categories were truncated, try closing the array - if (substr($label, -2) != '"]') { - $label .= '"]'; - } - $decoded = @Piwik_Common::json_decode($label); - if (is_array($decoded)) { - $count = 0; - foreach ($decoded as $category) { - if (empty($category) - || $count >= Piwik_Tracker_GoalManager::MAXIMUM_PRODUCT_CATEGORIES - ) { - continue; - } - if (!isset($this->interestByCustomVariablesAndValue[$row[$keyField]][$category])) { - $this->interestByCustomVariablesAndValue[$row[$keyField]][$category] = $archiveProcessing->getNewInterestRow($onlyMetricsAvailableInActionsTable); - } - $archiveProcessing->updateInterestStats($row, $this->interestByCustomVariablesAndValue[$row[$keyField]][$category], $onlyMetricsAvailableInActionsTable); - $mustInsertCustomVariableValue = false; - $count++; - } - } - } // end multi categories hack - - if ($mustInsertCustomVariableValue) { - if (!isset($this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]])) $this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]] = $archiveProcessing->getNewInterestRow($onlyMetricsAvailableInActionsTable); - $archiveProcessing->updateInterestStats($row, $this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]], $onlyMetricsAvailableInActionsTable); - } - - // Do not report on Price viewed for the Custom Variable names - unset($row[Piwik_Archive::INDEX_ECOMMERCE_ITEM_PRICE_VIEWED]); - - // When tracking Custom Variables with scope=page we do not add up visits numbers - // as it is incorrect to sum visits this way - // for scope=visit this is allowed, since there is supposed to be one custom var value per custom variable name for a given visit - $doNotSumVisits = true; - - if (!isset($this->interestByCustomVariables[$row[$keyField]])) $this->interestByCustomVariables[$row[$keyField]] = $archiveProcessing->getNewInterestRow($onlyMetricsAvailableInActionsTable, $doNotSumVisits); - $archiveProcessing->updateInterestStats($row, $this->interestByCustomVariables[$row[$keyField]], $onlyMetricsAvailableInActionsTable, $doNotSumVisits); - } - - // Custom Vars names and values metrics for Goals - $query = $archiveProcessing->queryConversionsByDimension($dimensions, $where); - - if ($query !== false) { - while ($row = $query->fetch()) { - // Handle case custom var value is empty - $row[$valueField] = $this->cleanCustomVarValue($row[$valueField]); - - if (!isset($this->interestByCustomVariables[$row[$keyField]][Piwik_Archive::INDEX_GOALS][$row['idgoal']])) $this->interestByCustomVariables[$row[$keyField]][Piwik_Archive::INDEX_GOALS][$row['idgoal']] = $archiveProcessing->getNewGoalRow($row['idgoal']); - if (!isset($this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]][Piwik_Archive::INDEX_GOALS][$row['idgoal']])) $this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]][Piwik_Archive::INDEX_GOALS][$row['idgoal']] = $archiveProcessing->getNewGoalRow($row['idgoal']); - - $archiveProcessing->updateGoalStats($row, $this->interestByCustomVariables[$row[$keyField]][Piwik_Archive::INDEX_GOALS][$row['idgoal']]); - $archiveProcessing->updateGoalStats($row, $this->interestByCustomVariablesAndValue[$row[$keyField]][$row[$valueField]][Piwik_Archive::INDEX_GOALS][$row['idgoal']]); - } - } - } - $archiveProcessing->enrichConversionsByLabelArray($this->interestByCustomVariables); - $archiveProcessing->enrichConversionsByLabelArrayHasTwoLevels($this->interestByCustomVariablesAndValue); - } - - protected function cleanCustomVarValue($value) - { - if (strlen($value)) { - return $value; - } - return self::LABEL_CUSTOM_VALUE_NOT_DEFINED; - } + /** @var Piwik_ArchiveProcessing_Day $archiveProcessing */ + $archiveProcessing = $notification->getNotificationObject(); - /** - * @param Piwik_ArchiveProcessing $archiveProcessing - * @return void - */ - protected function archiveDayRecordInDatabase($archiveProcessing) - { - $recordName = 'CustomVariables_valueByName'; - $table = $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByCustomVariablesAndValue, $this->interestByCustomVariables); + if (!$archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) return; - $blob = $table->getSerialized( - $this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, - $columnToSort = Piwik_Archive::INDEX_NB_VISITS); - $archiveProcessing->insertBlobRecord($recordName, $blob); - destroy($table); + $archiving = new Piwik_CustomVariables_Archiving(); + $archiving->archiveDay($archiveProcessing); } /** * @param Piwik_Event_Notification $notification notification object - * @return mixed */ function archivePeriod($notification) { @@ -320,9 +166,8 @@ class Piwik_CustomVariables extends Piwik_Plugin if (!$archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) return; - $dataTableToSum = 'CustomVariables_valueByName'; - $nameToCount = $archiveProcessing->archiveDataTable( - $dataTableToSum, null, $this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, - $columnToSort = Piwik_Archive::INDEX_NB_VISITS); + $archiving = new Piwik_CustomVariables_Archiving(); + $archiving->archivePeriod($archiveProcessing); } + } |