Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2015-10-30 23:09:19 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-11-04 23:02:09 +0300
commit89eb98b2fdaf3fa72a4a038daa050764f904ecc6 (patch)
tree2780a76f14724cb5546cfce657ede275d6ab3b85 /plugins/CustomVariables/Archiver.php
parent71c972da727f1f97c5fc13eb491daa77ff516de6 (diff)
added screen to see custom variable usages
Diffstat (limited to 'plugins/CustomVariables/Archiver.php')
-rw-r--r--plugins/CustomVariables/Archiver.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php
index bc43cbc8dd..4a53ab78df 100644
--- a/plugins/CustomVariables/Archiver.php
+++ b/plugins/CustomVariables/Archiver.php
@@ -8,7 +8,6 @@
*/
namespace Piwik\Plugins\CustomVariables;
-use Piwik\Common;
use Piwik\Config;
use Piwik\DataAccess\LogAggregator;
use Piwik\DataArray;
@@ -35,6 +34,9 @@ class Archiver extends \Piwik\Plugin\Archiver
protected $maximumRowsInSubDataTable;
protected $newEmptyRow;
+ private $metadata = array();
+ private $metadataFlat = array();
+
function __construct($processor)
{
parent::__construct($processor);
@@ -74,6 +76,16 @@ class Archiver extends \Piwik\Plugin\Archiver
$this->removeVisitsMetricsFromActionsAggregate();
$this->dataArray->enrichMetricsWithConversions();
$table = $this->dataArray->asDataTable();
+
+ foreach ($table->getRows() as $row) {
+ $label = $row->getColumn('label');
+ if (!empty($this->metadata[$label])) {
+ foreach ($this->metadata[$label] as $name => $value) {
+ $row->addMetadata($name, $value);
+ }
+ }
+ }
+
$blob = $table->getSerialized(
$this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable,
$columnToSort = Metrics::INDEX_NB_VISITS
@@ -118,6 +130,8 @@ class Archiver extends \Piwik\Plugin\Archiver
$key = $row[$keyField];
$value = $this->cleanCustomVarValue($row[$valueField]);
+ $this->addMetadata($keyField, $key, Model::SCOPE_VISIT);
+
$this->dataArray->sumMetricsVisits($key, $row);
$this->dataArray->sumMetricsVisitsPivot($key, $value, $row);
}
@@ -137,6 +151,8 @@ class Archiver extends \Piwik\Plugin\Archiver
$key = $row[$keyField];
$value = $this->cleanCustomVarValue($row[$valueField]);
+ $this->addMetadata($keyField, $key, Model::SCOPE_PAGE);
+
$alreadyAggregated = $this->aggregateEcommerceCategories($key, $value, $row);
if (!$alreadyAggregated) {
$this->aggregateActionByKeyAndValue($key, $value, $row);
@@ -145,6 +161,22 @@ class Archiver extends \Piwik\Plugin\Archiver
}
}
+ private function addMetadata($keyField, $label, $scope)
+ {
+ $index = (int) str_replace('custom_var_k', '', $keyField);
+
+ if (!array_key_exists($label, $this->metadata)) {
+ $this->metadata[$label] = array('slots' => array());
+ }
+
+ $uniqueId = $label . 'scope' . $scope . 'index' . $index;
+
+ if (!isset($this->metadataFlat[$uniqueId])) {
+ $this->metadata[$label]['slots'][] = array('scope' => $scope, 'index' => $index);
+ $this->metadataFlat[$uniqueId] = true;
+ }
+ }
+
/**
* @param string $key
* @param string $value
@@ -205,6 +237,7 @@ class Archiver extends \Piwik\Plugin\Archiver
}
while ($row = $query->fetch()) {
$key = $row[$keyField];
+
$value = $this->cleanCustomVarValue($row[$valueField]);
$this->dataArray->sumMetricsGoals($key, $row);
$this->dataArray->sumMetricsGoalsPivot($key, $value, $row);