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:
authormattab <matthieu.aubry@gmail.com>2013-06-06 11:26:36 +0400
committermattab <matthieu.aubry@gmail.com>2013-06-06 11:26:36 +0400
commit3fe760eaf2c811978f1ca6ba8056c50983a40f99 (patch)
tree2d5c0e2503045d02ac0ca1c407d86cf66c17a9a2
parent23b825db3025eecfe5f0979eb1d255d51ce2e5e2 (diff)
Removing what seems to be unused code? @sgiehl you added it but I cant find any code calling generateDatatable.
-rw-r--r--core/ArchiveProcessing/Day.php70
-rw-r--r--core/PluginsArchiver.php1
-rw-r--r--plugins/CustomVariables/Archiver.php4
-rw-r--r--plugins/Referers/Archiver.php50
-rw-r--r--plugins/UserCountry/Archiver.php2
-rw-r--r--plugins/UserSettings/Archiver.php7
-rw-r--r--plugins/VisitTime/Archiver.php2
-rw-r--r--tests/PHPUnit/Core/ArchiveProcessing/DayTest.php260
8 files changed, 43 insertions, 353 deletions
diff --git a/core/ArchiveProcessing/Day.php b/core/ArchiveProcessing/Day.php
index f2e72a9e40..2e6aaad305 100644
--- a/core/ArchiveProcessing/Day.php
+++ b/core/ArchiveProcessing/Day.php
@@ -157,8 +157,7 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
* ie (AND, OR, etc.).
* @return array An array of SQL SELECT expressions.
*/
- public static function buildReduceByRangeSelect(
- $column, $ranges, $table, $selectColumnPrefix = '', $extraCondition = false)
+ public static function buildReduceByRangeSelect( $column, $ranges, $table, $selectColumnPrefix = '', $extraCondition = false)
{
$selects = array();
@@ -662,67 +661,6 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
return $metrics;
}
- /**
- * Generates a dataTable given a multidimensional PHP array that associates LABELS to Piwik_DataTableRows
- * This is used for the "Actions" DataTable, where a line is the aggregate of all the subtables
- * Example: the category /blog has 3 visits because it has /blog/index (2 visits) + /blog/about (1 visit)
- *
- * @param array $table
- * @param array $parents
- * @return Piwik_DataTable
- */
- static public function generateDataTable($table, $parents = array())
- {
- $dataTableToReturn = new Piwik_DataTable();
- foreach ($table as $label => $maybeDatatableRow) {
- // case the aInfo is a subtable-like array
- // it means that we have to go recursively and process it
- // then we build the row that is an aggregate of all the children
- // and we associate this row to the subtable
- if (!($maybeDatatableRow instanceof Piwik_DataTable_Row)) {
- array_push($parents, array($dataTableToReturn->getId(), $label));
-
- $subTable = self::generateDataTable($maybeDatatableRow, $parents);
- $subTable->setParents($parents);
- $row = new Piwik_DataTable_Row_DataTableSummary($subTable);
- $row->setColumns(array('label' => $label) + $row->getColumns());
- $row->addSubtable($subTable);
-
- array_pop($parents);
- } // if aInfo is a simple Row we build it
- else {
- $row = $maybeDatatableRow;
- }
-
- if ($row->getMetadata('issummaryrow') == true) {
- $row->deleteMetadata('issummaryrow');
- $dataTableToReturn->addSummaryRow($row);
- } else {
- $dataTableToReturn->addRow($row);
- }
- }
- return $dataTableToReturn;
- }
-
- /**
- * Helper function that returns the serialized DataTable of the given PHP array.
- * The array must have the format of Piwik_DataTable::addRowsFromArrayWithIndexLabel()
- * Example: array (
- * LABEL => array(col1 => X, col2 => Y),
- * LABEL2 => array(col1 => X, col2 => Y),
- * )
- *
- * @param array $array at the given format
- * @return array Array with one element: the serialized data table string
- */
- public function getDataTableSerialized($array)
- {
- $table = new Piwik_DataTable();
- $table->addRowsFromArrayWithIndexLabel($array);
- $toReturn = $table->getSerialized();
- return $toReturn;
- }
-
/**
* Helper function that returns the multiple serialized DataTable of the given PHP array.
@@ -920,7 +858,7 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
*
* @param array $metricsByLabel Passed by reference, will be modified
*/
- function enrichConversionsByLabelArray(&$metricsByLabel)
+ function enrichMetricsWithConversions(&$metricsByLabel)
{
foreach ($metricsByLabel as $label => &$values) {
if (isset($values[Piwik_Archive::INDEX_GOALS])) {
@@ -950,10 +888,10 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
*
* @param array $metricsByLabelAndSubLabel Passed by reference, will be modified
*/
- function enrichConversionsByLabelArrayHasTwoLevels(&$metricsByLabelAndSubLabel)
+ function enrichPivotMetricsWithConversions(&$metricsByLabelAndSubLabel)
{
foreach ($metricsByLabelAndSubLabel as $mainLabel => &$metricsBySubLabel) {
- $this->enrichConversionsByLabelArray($metricsBySubLabel);
+ $this->enrichMetricsWithConversions($metricsBySubLabel);
}
}
diff --git a/core/PluginsArchiver.php b/core/PluginsArchiver.php
index ac8cc924b6..d29497f042 100644
--- a/core/PluginsArchiver.php
+++ b/core/PluginsArchiver.php
@@ -26,6 +26,7 @@ abstract class Piwik_PluginsArchiver
abstract public function archivePeriod();
+ // TODO: Review this concept / each plugin should somehow maintain the list of report names they generate
public function shouldArchive()
{
$pluginName = Piwik::unprefixClass(get_class($this));
diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php
index 2aab034424..896b5335bc 100644
--- a/plugins/CustomVariables/Archiver.php
+++ b/plugins/CustomVariables/Archiver.php
@@ -33,8 +33,8 @@ class Piwik_CustomVariables_Archiver extends Piwik_PluginsArchiver
}
$this->removeVisitsMetricsFromActionsAggregate();
- $this->getProcessor()->enrichConversionsByLabelArray($this->metricsByKey);
- $this->getProcessor()->enrichConversionsByLabelArrayHasTwoLevels($this->metricsByKeyAndValue);
+ $this->getProcessor()->enrichMetricsWithConversions($this->metricsByKey);
+ $this->getProcessor()->enrichPivotMetricsWithConversions($this->metricsByKeyAndValue);
$table = $this->getProcessor()->getDataTableWithSubtablesFromArraysIndexedByLabel($this->metricsByKeyAndValue, $this->metricsByKey);
$blob = $table->getSerialized(
diff --git a/plugins/Referers/Archiver.php b/plugins/Referers/Archiver.php
index 9da5998871..f540d1c2a2 100644
--- a/plugins/Referers/Archiver.php
+++ b/plugins/Referers/Archiver.php
@@ -164,12 +164,12 @@ class Piwik_Referers_Archiver extends Piwik_PluginsArchiver
}
}
- $this->getProcessor()->enrichConversionsByLabelArray($this->metricsByType);
- $this->getProcessor()->enrichConversionsByLabelArray($this->metricsBySearchEngine);
- $this->getProcessor()->enrichConversionsByLabelArray($this->metricsByKeyword);
- $this->getProcessor()->enrichConversionsByLabelArray($this->metricsByWebsite);
- $this->getProcessor()->enrichConversionsByLabelArray($this->metricsByCampaign);
- $this->getProcessor()->enrichConversionsByLabelArrayHasTwoLevels($this->metricsByCampaignAndKeyword);
+ $this->getProcessor()->enrichMetricsWithConversions($this->metricsByType);
+ $this->getProcessor()->enrichMetricsWithConversions($this->metricsBySearchEngine);
+ $this->getProcessor()->enrichMetricsWithConversions($this->metricsByKeyword);
+ $this->getProcessor()->enrichMetricsWithConversions($this->metricsByWebsite);
+ $this->getProcessor()->enrichMetricsWithConversions($this->metricsByCampaign);
+ $this->getProcessor()->enrichPivotMetricsWithConversions($this->metricsByCampaignAndKeyword);
}
protected function aggregateConversion($row)
@@ -254,21 +254,15 @@ class Piwik_Referers_Archiver extends Piwik_PluginsArchiver
*/
protected function recordDayReports()
{
- $numericRecords = array(
- 'Referers_distinctSearchEngines' => count($this->metricsBySearchEngineAndKeyword),
- 'Referers_distinctKeywords' => count($this->metricsByKeywordAndSearchEngine),
- 'Referers_distinctCampaigns' => count($this->metricsByCampaign),
- 'Referers_distinctWebsites' => count($this->metricsByWebsite),
- 'Referers_distinctWebsitesUrls' => count($this->distinctUrls),
- );
-
- foreach ($numericRecords as $name => $value) {
- $this->getProcessor()->insertNumericRecord($name, $value);
- }
+ $this->recordDayNumeric();
+ $this->recordDayBlobs();
+ }
- $dataTable = $this->getProcessor()->getDataTableSerialized($this->metricsByType);
- $this->getProcessor()->insertBlobRecord('Referers_type', $dataTable);
- destroy($dataTable);
+ protected function recordDayBlobs()
+ {
+ $table = new Piwik_DataTable();
+ $table->addRowsFromArrayWithIndexLabel($this->metricsByType);
+ $this->getProcessor()->insertBlobRecord('Referers_type', $table->getSerialized());
$blobRecords = array(
'Referers_keywordBySearchEngine' => $this->getProcessor()->getDataTableWithSubtablesFromArraysIndexedByLabel($this->metricsBySearchEngineAndKeyword, $this->metricsBySearchEngine),
@@ -279,7 +273,21 @@ class Piwik_Referers_Archiver extends Piwik_PluginsArchiver
foreach ($blobRecords as $recordName => $table) {
$blob = $table->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord($recordName, $blob);
- destroy($table);
+ }
+ }
+
+ protected function recordDayNumeric()
+ {
+ $numericRecords = array(
+ 'Referers_distinctSearchEngines' => count($this->metricsBySearchEngineAndKeyword),
+ 'Referers_distinctKeywords' => count($this->metricsByKeywordAndSearchEngine),
+ 'Referers_distinctCampaigns' => count($this->metricsByCampaign),
+ 'Referers_distinctWebsites' => count($this->metricsByWebsite),
+ 'Referers_distinctWebsitesUrls' => count($this->distinctUrls),
+ );
+
+ foreach ($numericRecords as $name => $value) {
+ $this->getProcessor()->insertNumericRecord($name, $value);
}
}
diff --git a/plugins/UserCountry/Archiver.php b/plugins/UserCountry/Archiver.php
index 5f2a30310b..bdd7c10f02 100644
--- a/plugins/UserCountry/Archiver.php
+++ b/plugins/UserCountry/Archiver.php
@@ -139,7 +139,7 @@ class Piwik_UserCountry_Archiver extends Piwik_PluginsArchiver
}
foreach ($this->metricsByDimension as &$table) {
- $this->getProcessor()->enrichConversionsByLabelArray($table);
+ $this->getProcessor()->enrichMetricsWithConversions($table);
}
}
diff --git a/plugins/UserSettings/Archiver.php b/plugins/UserSettings/Archiver.php
index d8039d9fd7..fa8721c6e7 100644
--- a/plugins/UserSettings/Archiver.php
+++ b/plugins/UserSettings/Archiver.php
@@ -109,8 +109,11 @@ class Piwik_UserSettings_Archiver extends Piwik_PluginsArchiver
sum(case log_visit.config_gears when 1 then 1 else 0 end) as gears,
sum(case log_visit.config_silverlight when 1 then 1 else 0 end) as silverlight,
sum(case log_visit.config_cookie when 1 then 1 else 0 end) as cookie ";
- $table = $this->getProcessor()->getSimpleDataTableFromSelect($toSelect, Piwik_Archive::INDEX_NB_VISITS);
- $this->getProcessor()->insertBlobRecord(self::PLUGIN_RECORD_NAME, $table->getSerialized());
+
+ $processor = $this->getProcessor();
+ $data = $processor->queryVisitsSimple($toSelect);
+ $table = $processor->getSimpleDataTableFromRow($data, Piwik_Archive::INDEX_NB_VISITS);
+ $processor->insertBlobRecord(self::PLUGIN_RECORD_NAME, $table->getSerialized());
}
protected function aggregateByLanguage()
diff --git a/plugins/VisitTime/Archiver.php b/plugins/VisitTime/Archiver.php
index 36b3c94aeb..52d3bdbc7f 100644
--- a/plugins/VisitTime/Archiver.php
+++ b/plugins/VisitTime/Archiver.php
@@ -30,7 +30,7 @@ class Piwik_VisitTime_Archiver extends Piwik_PluginsArchiver
}
$this->getProcessor()->sumGoalMetrics($row, $metricsByServerTime[$row['label']][Piwik_Archive::INDEX_GOALS][$row['idgoal']]);
}
- $this->getProcessor()->enrichConversionsByLabelArray($metricsByServerTime);
+ $this->getProcessor()->enrichMetricsWithConversions($metricsByServerTime);
$metricsByServerTime = $this->convertServerTimeToLocalTimezone($metricsByServerTime);
$tableServerTime = $this->getProcessor()->getDataTableFromArray($metricsByServerTime);
diff --git a/tests/PHPUnit/Core/ArchiveProcessing/DayTest.php b/tests/PHPUnit/Core/ArchiveProcessing/DayTest.php
deleted file mode 100644
index 369b0ef2a3..0000000000
--- a/tests/PHPUnit/Core/ArchiveProcessing/DayTest.php
+++ /dev/null
@@ -1,260 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- */
-class ArchiveProcessing_DayTest extends PHPUnit_Framework_TestCase
-{
- /**
- * @group Core
- * @group ArchiveProcessing
- * @group ArchiveProcessing_Day
- */
- public function testGenerateDataTableSimple()
- {
- $row1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'page1', 'visits' => 1, 'actions' => 2, '666' => 'evil')));
-
- $input = array(
- 'page1' => $row1,
- );
-
- $table = new Piwik_DataTable;
- $table->addRow($row1);
-
- $tableGenerated = Piwik_ArchiveProcessing_Day::generateDataTable($input);
-
- $this->assertTrue(Piwik_DataTable::isEqual($table, $tableGenerated));
- }
-
- /**
- * @group Core
- * @group ArchiveProcessing
- * @group ArchiveProcessing_Day
- */
- public function testGenerateDataTable2rows()
- {
- $row1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'page1', 'visits' => 1, 'actions' => 2)));
- $row2 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'page2', 'visits' => 3, 'actions' => 5)));
-
- $input = array(
- 'page1' => $row1,
- 'page2' => $row2,
- );
-
- $table = new Piwik_DataTable;
- $table->addRow($row1);
- $table->addRow($row2);
-
- $tableGenerated = Piwik_ArchiveProcessing_Day::generateDataTable($input);
-
- $this->assertTrue(Piwik_DataTable::isEqual($table, $tableGenerated));
- }
-
- /**
- * @group Core
- * @group ArchiveProcessing
- * @group ArchiveProcessing_Day
- */
- public function testGenerateDataTable1row2level()
- {
- $row1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'cat1', 'visits' => 3, 'actions' => 5)));
-
- $rowLevel2 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'page1', 'visits' => 3, 'actions' => 5)));
- $subtable = new Piwik_DataTable;
- $subtable->addRow($rowLevel2);
- $row1->addSubtable($subtable);
-
- $table = new Piwik_DataTable;
- $table->addRow($row1);
-
- $input = array(
- 'cat1' => array(
- 'page1' => $rowLevel2,
- )
- );
-
- $tableGenerated = Piwik_ArchiveProcessing_Day::generateDataTable($input);
-
- $r1 = new Piwik_DataTable_Renderer_Console();
- $r1->setTable($table);
- $r2 = new Piwik_DataTable_Renderer_Console();
- $r2->setTable($tableGenerated);
-
- $this->assertTrue(Piwik_DataTable::isEqual($table, $tableGenerated));
- }
-
- /**
- * @group Core
- * @group ArchiveProcessing
- * @group ArchiveProcessing_Day
- */
- public function testGenerateDataTable2rows2level()
- {
- $table = new Piwik_DataTable;
-
- //FIRST ROW + SUBTABLE
- $row1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'cat1', 'visits' => 3, 'actions' => 5)));
-
- $rowLevel2a = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'page1', 'visits' => 3, 'actions' => 5)));
- $subtable = new Piwik_DataTable;
- $subtable->addRow($rowLevel2a);
- $row1->addSubtable($subtable);
-
- //-- add
- $table->addRow($row1);
-
- //SECOND ROW + SUBTABLE MULTI ROWS
- $row1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'cat2', 'visits' => 13, 'actions' => 9)));
-
- $rowLevel2b1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'page2a', 'visits' => 6, 'actions' => 8)));
-
- $rowLevel2b2 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'page2b', 'visits' => 7, 'actions' => 1)));
- $subtable = new Piwik_DataTable;
- $subtable->addRow($rowLevel2b1);
- $subtable->addRow($rowLevel2b2);
- $row1->addSubtable($subtable);
-
- //-- add
- $table->addRow($row1);
-
- // WHAT WE TEST
- $input = array(
- 'cat1' => array(
- 'page1' => $rowLevel2a,
- ),
- 'cat2' => array(
- 'page2a' => $rowLevel2b1,
- 'page2b' => $rowLevel2b2,
- )
- );
- $tableGenerated = Piwik_ArchiveProcessing_Day::generateDataTable($input);
-
- $r1 = new Piwik_DataTable_Renderer_Console();
- $r1->setTable($table);
- $r2 = new Piwik_DataTable_Renderer_Console();
- $r2->setTable($tableGenerated);
-
- $this->assertTrue(Piwik_DataTable::isEqual($table, $tableGenerated));
- }
-
- /**
- * @group Core
- * @group ArchiveProcessing
- * @group ArchiveProcessing_Day
- */
- public function testGenerateDataTable1row4levelMultiRows()
- {
- $table = new Piwik_DataTable;
-
- //FIRST ROW + SUBTABLE
- $rowcat2 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => '456', 'visits' => 3, 'actions' => 5)));
-
- $cat2 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'cat2', 'visits' => 3, 'actions' => 5)));
-
- $rowcat1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'pagecat1', 'visits' => 6, 'actions' => 4)));
-
- $cat1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'cat1', 'visits' => 9, 'actions' => 9)));
-
- $subtablecat2 = new Piwik_DataTable;
- $subtablecat2->addRow($rowcat2);
- $cat2->addSubtable($subtablecat2);
-
- $subtablecat1 = new Piwik_DataTable;
- $subtablecat1->addRow($rowcat1);
- $subtablecat1->addRow($cat2);
-
- $cat1->addSubtable($subtablecat1);
-
- //-- add
- $table->addRow($cat1);
-
- // WHAT WE TEST
- $input = array(
- 'cat1' => array(
- 'pagecat1' => $rowcat1,
- 'cat2' => array(
- 'pagecat2' => $rowcat2,
- ),
- ),
- );
- $tableGenerated = Piwik_ArchiveProcessing_Day::generateDataTable($input);
-
- $r1 = new Piwik_DataTable_Renderer_Console();
- $r1->setTable($table);
- $r2 = new Piwik_DataTable_Renderer_Console();
- $r2->setTable($tableGenerated);
-
- $this->assertTrue(Piwik_DataTable::isEqual($table, $tableGenerated));
- }
-
- /**
- * @group Core
- * @group ArchiveProcessing
- * @group ArchiveProcessing_Day
- */
- public function testGenerateDataTable1row4level()
- {
- $table = new Piwik_DataTable;
-
- $rowpagecat3 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => '123123', 'visits' => 3, 'actions' => 5)));
-
- $rowcat3 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => '789.654', 'visits' => 3, 'actions' => 5)));
- $rowcat2 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => 'cat2', 'visits' => 3, 'actions' => 5)));
- $rowcat1 = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS =>
- array('label' => '&*()', 'visits' => 3, 'actions' => 5)));
-
- $subtablerowpagecat3 = new Piwik_DataTable;
- $subtablerowpagecat3->addRow($rowpagecat3);
- $rowcat3->addSubtable($subtablerowpagecat3);
-
- $subtablecat2 = new Piwik_DataTable;
- $subtablecat2->addRow($rowcat3);
- $rowcat2->addSubtable($subtablecat2);
-
-
- $subtablecat1 = new Piwik_DataTable;
- $subtablecat1->addRow($rowcat2);
- $rowcat1->addSubtable($subtablecat1);
-
- //-- add
- $table->addRow($rowcat1);
-
- // WHAT WE TEST
- $input = array(
- '&*()' => array(
- 'cat2' => array(
- '789.654' => array(
- '123123' => $rowpagecat3,
- ),
- ),
- ),
- );
-
- $tableGenerated = Piwik_ArchiveProcessing_Day::generateDataTable($input);
-
- $r1 = new Piwik_DataTable_Renderer_Console();
- $r1->setTable($table);
- $r2 = new Piwik_DataTable_Renderer_Console();
- $r2->setTable($tableGenerated);
- $this->assertTrue(Piwik_DataTable::isEqual($table, $tableGenerated));
- }
-}