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:
Diffstat (limited to 'plugins/CustomDimensions/DataArray.php')
m---------plugins/CustomDimensions0
-rw-r--r--plugins/CustomDimensions/DataArray.php54
2 files changed, 54 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions
deleted file mode 160000
-Subproject 318661a2fb1ef3b3e5d6d999ae8b9628cb5a113
diff --git a/plugins/CustomDimensions/DataArray.php b/plugins/CustomDimensions/DataArray.php
new file mode 100644
index 0000000000..5e87c07954
--- /dev/null
+++ b/plugins/CustomDimensions/DataArray.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CustomDimensions;
+
+use Piwik\Metrics;
+
+/**
+ * The DataArray is a data structure used to aggregate datasets,
+ * ie. sum arrays made of rows made of columns,
+ * data from the logs is stored in a DataArray before being converted in a DataTable
+ *
+ */
+
+class DataArray extends \Piwik\DataArray
+{
+ private static $actionMetrics = array();
+
+ public function setActionMetricsIds($metrics)
+ {
+ self::$actionMetrics = $metrics;
+ }
+
+ protected static function makeEmptyActionRow()
+ {
+ $metrics = array();
+
+ foreach (self::$actionMetrics as $key) {
+ $metrics[$key] = 0;
+ }
+
+ return $metrics;
+ }
+
+ protected function doSumActionsMetrics($newRowToAdd, &$oldRowToUpdate)
+ {
+ foreach (self::$actionMetrics as $actionMetric) {
+ $oldRowToUpdate[$actionMetric] += $newRowToAdd[$actionMetric];
+ }
+ }
+
+ public function sumMetricsActionCustomDimensionsPivot($parentLabel, $label, $row)
+ {
+ if (!isset($this->dataTwoLevels[$parentLabel][$label])) {
+ $this->dataTwoLevels[$parentLabel][$label] = $this->makeEmptyActionRow();
+ }
+ $this->doSumActionsMetrics($row, $this->dataTwoLevels[$parentLabel][$label]);
+ }
+}