diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-02-26 05:23:28 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-03-05 05:31:18 +0300 |
commit | 287aad82841f0f0e85406192b2f1f865bc0be67d (patch) | |
tree | d9c035a484c3f2727d7fa1cdf14ccd213c308508 /plugins/Events/API.php | |
parent | a1cb3695319b321f92bb0a4fd31892a9bc1bdf38 (diff) |
Faster flattening for many reports
Diffstat (limited to 'plugins/Events/API.php')
-rw-r--r-- | plugins/Events/API.php | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/plugins/Events/API.php b/plugins/Events/API.php index bb6584b777..7950cd2637 100644 --- a/plugins/Events/API.php +++ b/plugins/Events/API.php @@ -148,14 +148,17 @@ class API extends \Piwik\Plugin\API } } - protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null, $secondaryDimension = false) + protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null, $secondaryDimension = false, $flat = false) { Piwik::checkUserHasViewAccess($idSite); $this->checkSecondaryDimension($name, $secondaryDimension); $recordName = $this->getRecordNameForAction($name, $secondaryDimension); - $dataTable = Archive::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable); - if (empty($idSubtable)) { + $dataTable = Archive::createDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $flat, $idSubtable); + + if ($flat) { + $dataTable->filterSubtables('Piwik\Plugins\Events\DataTable\Filter\ReplaceEventNameNotSet'); + } else { $dataTable->filter('AddSegmentValue', array(function ($label) { if ($label === Archiver::EVENT_NAME_NOT_SET) { return false; @@ -165,23 +168,24 @@ class API extends \Piwik\Plugin\API })); } - $this->filterDataTable($dataTable); + $dataTable->filter('Piwik\Plugins\Events\DataTable\Filter\ReplaceEventNameNotSet'); + return $dataTable; } - public function getCategory($idSite, $period, $date, $segment = false, $expanded = false, $secondaryDimension = false) + public function getCategory($idSite, $period, $date, $segment = false, $expanded = false, $secondaryDimension = false, $flat = false) { - return $this->getDataTable(__FUNCTION__, $idSite, $period, $date, $segment, $expanded, $idSubtable = false, $secondaryDimension); + return $this->getDataTable(__FUNCTION__, $idSite, $period, $date, $segment, $expanded, $idSubtable = false, $secondaryDimension, $flat); } - public function getAction($idSite, $period, $date, $segment = false, $expanded = false, $secondaryDimension = false) + public function getAction($idSite, $period, $date, $segment = false, $expanded = false, $secondaryDimension = false, $flat = false) { - return $this->getDataTable(__FUNCTION__, $idSite, $period, $date, $segment, $expanded, $idSubtable = false, $secondaryDimension); + return $this->getDataTable(__FUNCTION__, $idSite, $period, $date, $segment, $expanded, $idSubtable = false, $secondaryDimension, $flat); } - public function getName($idSite, $period, $date, $segment = false, $expanded = false, $secondaryDimension = false) + public function getName($idSite, $period, $date, $segment = false, $expanded = false, $secondaryDimension = false, $flat = false) { - return $this->getDataTable(__FUNCTION__, $idSite, $period, $date, $segment, $expanded, $idSubtable = false, $secondaryDimension); + return $this->getDataTable(__FUNCTION__, $idSite, $period, $date, $segment, $expanded, $idSubtable = false, $secondaryDimension, $flat); } public function getActionFromCategoryId($idSite, $period, $date, $idSubtable, $segment = false) @@ -213,20 +217,4 @@ class API extends \Piwik\Plugin\API { return $this->getDataTable(__FUNCTION__, $idSite, $period, $date, $segment, $expanded = false, $idSubtable); } - - /** - * @param DataTable $dataTable - */ - protected function filterDataTable($dataTable) - { - $dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS)); - $dataTable->queueFilter('ReplaceColumnNames'); - $dataTable->queueFilter('ReplaceSummaryRowLabel'); - $dataTable->filter(function (DataTable $table) { - $row = $table->getRowFromLabel(Archiver::EVENT_NAME_NOT_SET); - if ($row) { - $row->setColumn('label', Piwik::translate('General_NotDefined', Piwik::translate('Events_EventName'))); - } - }); - } }
\ No newline at end of file |