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
path: root/core
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2015-03-10 02:24:04 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-03-11 04:34:47 +0300
commit2a1dcbd35ec0fd8dd8a384fe00671bf37ec7fd3e (patch)
tree9e73d85aa8bd9f354bb695c5d5484655f77d46f3 /core
parent3db2044b94b411ac7c13e417582d06cd9c760acf (diff)
Made for reports faster when flat=1 is used.
Also replaceColumnNames is now queued again which should bring a performance boost in general.
Diffstat (limited to 'core')
-rw-r--r--core/Archive.php6
-rw-r--r--core/DataTable.php19
-rw-r--r--core/DataTable/Filter/Sort.php4
-rw-r--r--core/DataTable/Map.php27
4 files changed, 53 insertions, 3 deletions
diff --git a/core/Archive.php b/core/Archive.php
index c7eb6e3106..0499756410 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -498,7 +498,11 @@ class Archive
$dataTable = self::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable, $depth);
- $dataTable->filter('ReplaceColumnNames');
+ $dataTable->queueFilter('ReplaceColumnNames');
+
+ if ($expanded) {
+ $dataTable->queueFilterSubtables('ReplaceColumnNames');
+ }
if ($flat) {
$dataTable->disableRecursiveFilters();
diff --git a/core/DataTable.php b/core/DataTable.php
index 0b0d9845f0..935ee34bfa 100644
--- a/core/DataTable.php
+++ b/core/DataTable.php
@@ -489,6 +489,25 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
}
/**
+ * Applies a filter to all subtables but not to this datatable.
+ *
+ * @param string|Closure $className Class name, eg. `"Sort"` or "Piwik\DataTable\Filters\Sort"`. If no
+ * namespace is supplied, `Piwik\DataTable\BaseFilter` is assumed. This parameter
+ * can also be a closure that takes a DataTable as its first parameter.
+ * @param array $parameters Array of extra parameters to pass to the filter.
+ */
+ public function queueFilterSubtables($className, $parameters = array())
+ {
+ foreach ($this->getRows() as $row) {
+ $subtable = $row->getSubtable();
+ if ($subtable) {
+ $subtable->queueFilter($className, $parameters);
+ $subtable->queueFilterSubtables($className, $parameters);
+ }
+ }
+ }
+
+ /**
* Adds a filter and a list of parameters to the list of queued filters. These filters will be
* executed when {@link applyQueuedFilters()} is called.
*
diff --git a/core/DataTable/Filter/Sort.php b/core/DataTable/Filter/Sort.php
index 632da35dc8..3da11b4119 100644
--- a/core/DataTable/Filter/Sort.php
+++ b/core/DataTable/Filter/Sort.php
@@ -143,9 +143,9 @@ Sort extends BaseFilter
);
}
- protected function getColumnValue(Row $table )
+ protected function getColumnValue(Row $row)
{
- $value = $table->getColumn($this->columnToSort);
+ $value = $row->getColumn($this->columnToSort);
if ($value === false
|| is_array($value)
diff --git a/core/DataTable/Map.php b/core/DataTable/Map.php
index 8787b06404..ccf201c5be 100644
--- a/core/DataTable/Map.php
+++ b/core/DataTable/Map.php
@@ -123,6 +123,19 @@ class Map implements DataTableInterface
}
/**
+ * Apply a queued filter to all subtables contained by this instance.
+ *
+ * @param string|Closure $className Name of filter class or a Closure.
+ * @param array $parameters Parameters to pass to the filter.
+ */
+ public function queueFilterSubtables($className, $parameters = array())
+ {
+ foreach ($this->getDataTables() as $table) {
+ $table->queueFilterSubtables($className, $parameters);
+ }
+ }
+
+ /**
* Returns the array of DataTables contained by this class.
*
* @return DataTable[]|Map[]
@@ -174,6 +187,20 @@ class Map implements DataTableInterface
$this->array[$label] = $table;
}
+ public function getRowFromIdSubDataTable($idSubtable)
+ {
+ $dataTables = $this->getDataTables();
+
+ // find first datatable containing data
+ foreach ($dataTables as $subTable) {
+ $subTableRow = $subTable->getRowFromIdSubDataTable($idSubtable);
+
+ if (!empty($subTableRow)) {
+ return $subTableRow;
+ }
+ }
+ }
+
/**
* Returns a string output of this DataTable\Map (applying the default renderer to every {@link DataTable}
* of this DataTable\Map).