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-02-26 05:23:28 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-03-05 05:31:18 +0300
commit287aad82841f0f0e85406192b2f1f865bc0be67d (patch)
treed9c035a484c3f2727d7fa1cdf14ccd213c308508 /core/Archive.php
parenta1cb3695319b321f92bb0a4fd31892a9bc1bdf38 (diff)
Faster flattening for many reports
Diffstat (limited to 'core/Archive.php')
-rw-r--r--core/Archive.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/core/Archive.php b/core/Archive.php
index 1931b6a343..c7eb6e3106 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -452,6 +452,7 @@ class Archive
* @return DataTable|DataTable\Map See {@link getDataTable()} and
* {@link getDataTableExpanded()} for more
* information
+ * @deprecated Since Piwik 2.12.0 Use Archive::createDataTableFromArchive() instead
*/
public static function getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded,
$idSubtable = null, $depth = null)
@@ -474,6 +475,38 @@ class Archive
return $dataTable;
}
+ /**
+ * Helper function that creates an Archive instance and queries for report data using
+ * query parameter data. API methods can use this method to reduce code redundancy.
+ *
+ * @param string $recordName The name of the report to return.
+ * @param int|string|array $idSite @see {@link build()}
+ * @param string $period @see {@link build()}
+ * @param string $date @see {@link build()}
+ * @param string $segment @see {@link build()}
+ * @param bool $expanded If true, loads all subtables. See {@link getDataTableExpanded()}
+ * @param bool $flat If true, loads all subtables and disabled all recursive filters.
+ * @param int|null $idSubtable See {@link getDataTableExpanded()}
+ * @param int|null $depth See {@link getDataTableExpanded()}
+ * @return DataTable|DataTable\Map
+ */
+ public static function createDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded = false, $flat = false, $idSubtable = null, $depth = null)
+ {
+ if ($flat && !$idSubtable) {
+ $expanded = true;
+ }
+
+ $dataTable = self::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable, $depth);
+
+ $dataTable->filter('ReplaceColumnNames');
+
+ if ($flat) {
+ $dataTable->disableRecursiveFilters();
+ }
+
+ return $dataTable;
+ }
+
private function appendIdSubtable($recordName, $id)
{
return $recordName . "_" . $id;