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:
authorMatthieu Aubry <matt@piwik.org>2015-03-02 10:04:12 +0300
committerMatthieu Aubry <matt@piwik.org>2015-03-02 10:04:12 +0300
commit586a33b1b1a3443960ed55b2d3bf9c9123374848 (patch)
tree39e33a10c5d58c799db935846425c96edfa8d1d8 /core
parent3d8fd5ab6c1835ce94ac774671b0a2a9d66f8f9d (diff)
parentb08b9295293668eb17aa21639bae932e915633cb (diff)
Merge pull request #7311 from piwik/remove_useseless_code
remove unused code & logic
Diffstat (limited to 'core')
-rw-r--r--core/Archive.php31
-rw-r--r--core/Archive/Parameters.php14
-rw-r--r--core/ArchiveProcessor.php33
-rw-r--r--core/ArchiveProcessor/Parameters.php8
-rw-r--r--core/ArchiveProcessor/Rules.php30
-rw-r--r--core/DataAccess/ArchiveSelector.php22
-rw-r--r--core/DataAccess/ArchiveWriter.php2
-rw-r--r--core/DataTable.php37
8 files changed, 56 insertions, 121 deletions
diff --git a/core/Archive.php b/core/Archive.php
index 60d6791726..1931b6a343 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -196,10 +196,9 @@ class Archive
* or date range (ie, 'YYYY-MM-DD,YYYY-MM-DD').
* @param bool|false|string $segment Segment definition or false if no segment should be used. {@link Piwik\Segment}
* @param bool|false|string $_restrictSitesToLogin Used only when running as a scheduled task.
- * @param bool $skipAggregationOfSubTables Whether the archive, when it is processed, should also aggregate all sub-tables
* @return Archive
*/
- public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false, $skipAggregationOfSubTables = false)
+ public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false)
{
$websiteIds = Site::getIdSitesFromIdSitesString($idSites, $_restrictSitesToLogin);
@@ -220,7 +219,7 @@ class Archive
$idSiteIsAll = $idSites == self::REQUEST_ALL_WEBSITES_FLAG;
$isMultipleDate = Period::isMultiplePeriod($strDate, $period);
- return Archive::factory($segment, $allPeriods, $websiteIds, $idSiteIsAll, $isMultipleDate, $skipAggregationOfSubTables);
+ return Archive::factory($segment, $allPeriods, $websiteIds, $idSiteIsAll, $isMultipleDate);
}
/**
@@ -242,11 +241,10 @@ class Archive
* @param bool $isMultipleDate Whether multiple dates are being queried or not. If true, then
* the result of querying functions will be indexed by period,
* regardless of whether `count($periods) == 1`.
- * @param bool $skipAggregationOfSubTables Whether the archive should skip aggregation of all sub-tables
*
* @return Archive
*/
- public static function factory(Segment $segment, array $periods, array $idSites, $idSiteIsAll = false, $isMultipleDate = false, $skipAggregationOfSubTables = false)
+ public static function factory(Segment $segment, array $periods, array $idSites, $idSiteIsAll = false, $isMultipleDate = false)
{
$forceIndexedBySite = false;
$forceIndexedByDate = false;
@@ -259,7 +257,7 @@ class Archive
$forceIndexedByDate = true;
}
- $params = new Parameters($idSites, $periods, $segment, $skipAggregationOfSubTables);
+ $params = new Parameters($idSites, $periods, $segment);
return new Archive($params, $forceIndexedBySite, $forceIndexedByDate);
}
@@ -449,7 +447,6 @@ class Archive
* @param string $segment @see {@link build()}
* @param bool $expanded If true, loads all subtables. See {@link getDataTableExpanded()}
* @param int|null $idSubtable See {@link getDataTableExpanded()}
- * @param bool $skipAggregationOfSubTables Whether or not we should skip the aggregation of all sub-tables and only aggregate parent DataTable.
* @param int|null $depth See {@link getDataTableExpanded()}
* @throws \Exception
* @return DataTable|DataTable\Map See {@link getDataTable()} and
@@ -457,15 +454,11 @@ class Archive
* information
*/
public static function getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded,
- $idSubtable = null, $skipAggregationOfSubTables = false, $depth = null)
+ $idSubtable = null, $depth = null)
{
Piwik::checkUserHasViewAccess($idSite);
- if ($skipAggregationOfSubTables && ($expanded || $idSubtable)) {
- throw new \Exception("Not expected to skipAggregationOfSubTables when expanded=1 or idSubtable is set.");
- }
-
- $archive = Archive::build($idSite, $period, $date, $segment, $_restrictSitesToLogin = false, $skipAggregationOfSubTables);
+ $archive = Archive::build($idSite, $period, $date, $segment, $_restrictSitesToLogin = false);
if ($idSubtable === false) {
$idSubtable = null;
}
@@ -607,6 +600,9 @@ class Archive
* queried. This function will use the idarchive cache if it has the right data,
* query archive tables for IDs w/o launching archiving, or launch archiving and
* get the idarchive from ArchiveProcessor instances.
+ *
+ * @param string $archiveNames
+ * @return array
*/
private function getArchiveIds($archiveNames)
{
@@ -698,7 +694,7 @@ class Archive
private function cacheArchiveIdsWithoutLaunching($plugins)
{
$idarchivesByReport = ArchiveSelector::getArchiveIds(
- $this->params->getIdSites(), $this->params->getPeriods(), $this->params->getSegment(), $plugins, $this->params->isSkipAggregationOfSubTables());
+ $this->params->getIdSites(), $this->params->getPeriods(), $this->params->getSegment(), $plugins);
// initialize archive ID cache for each report
foreach ($plugins as $plugin) {
@@ -726,8 +722,7 @@ class Archive
$this->params->getIdSites(),
$this->params->getSegment(),
$this->getPeriodLabel(),
- $plugin,
- $this->params->isSkipAggregationOfSubTables()
+ $plugin
);
}
@@ -794,6 +789,8 @@ class Archive
* If this function is not called, then periods with no visits will not add
* entries to the cache. If the archive is used again, SQL will be executed to
* try and find the archive IDs even though we know there are none.
+ *
+ * @param string $doneFlag
*/
private function initializeArchiveIdCache($doneFlag)
{
@@ -863,7 +860,7 @@ class Archive
*/
private function prepareArchive(array $archiveGroups, Site $site, Period $period)
{
- $parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment(), $this->params->isSkipAggregationOfSubTables());
+ $parameters = new ArchiveProcessor\Parameters($site, $period, $this->params->getSegment());
$archiveLoader = new ArchiveProcessor\Loader($parameters);
$periodString = $period->getRangeString();
diff --git a/core/Archive/Parameters.php b/core/Archive/Parameters.php
index d1a540dce0..ad7bef9eb6 100644
--- a/core/Archive/Parameters.php
+++ b/core/Archive/Parameters.php
@@ -35,22 +35,16 @@ class Parameters
*/
private $segment;
- /**
- * @var bool
- */
- private $skipAggregationOfSubTables;
-
public function getSegment()
{
return $this->segment;
}
- public function __construct($idSites, $periods, Segment $segment, $skipAggregationOfSubTables)
+ public function __construct($idSites, $periods, Segment $segment)
{
$this->idSites = $idSites;
$this->periods = $periods;
$this->segment = $segment;
- $this->skipAggregationOfSubTables = $skipAggregationOfSubTables;
}
public function getPeriods()
@@ -62,11 +56,5 @@ class Parameters
{
return $this->idSites;
}
-
- public function isSkipAggregationOfSubTables()
- {
- return $this->skipAggregationOfSubTables;
- }
-
}
diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index 17716000e8..a8254259e8 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -214,14 +214,9 @@ class ArchiveProcessor
$table = $this->aggregateDataTableRecord($recordName, $columnsAggregationOperation, $columnsToRenameAfterAggregation);
- $rowsCount = $table->getRowsCount();
- $nameToCount[$recordName]['level0'] = $rowsCount;
+ $nameToCount[$recordName]['level0'] = $table->getRowsCount();
- $rowsCountRecursive = $rowsCount;
- if ($this->isAggregateSubTables()) {
- $rowsCountRecursive = $table->getRowsCountRecursive();
- }
- $nameToCount[$recordName]['recursive'] = $rowsCountRecursive;
+ $nameToCount[$recordName]['recursive'] = $table->getRowsCountRecursive();
$blob = $table->getSerialized($maximumRowsInDataTableLevelZero, $maximumRowsInSubDataTable, $columnToSortByBeforeTruncation);
Common::destroy($table);
@@ -346,14 +341,8 @@ class ArchiveProcessor
*/
protected function aggregateDataTableRecord($name, $columnsAggregationOperation = null, $columnsToRenameAfterAggregation = null)
{
- if ($this->isAggregateSubTables()) {
- // By default we shall aggregate all sub-tables.
- $dataTable = $this->getArchive()->getDataTableExpanded($name, $idSubTable = null, $depth = null, $addMetadataSubtableId = false);
- } else {
- // In some cases (eg. Actions plugin when period=range),
- // for better performance we will only aggregate the parent table
- $dataTable = $this->getArchive()->getDataTable($name, $idSubTable = null);
- }
+ // By default we shall aggregate all sub-tables.
+ $dataTable = $this->getArchive()->getDataTableExpanded($name, $idSubTable = null, $depth = null, $addMetadataSubtableId = false);
if ($dataTable instanceof Map) {
// see https://github.com/piwik/piwik/issues/4377
@@ -471,7 +460,7 @@ class ArchiveProcessor
// as $date => $tableToSum
$this->aggregatedDataTableMapsAsOne($data, $table);
} else {
- $table->addDataTable($data, $this->isAggregateSubTables());
+ $table->addDataTable($data);
}
return $table;
@@ -488,7 +477,7 @@ class ArchiveProcessor
if ($tableToAggregate instanceof Map) {
$this->aggregatedDataTableMapsAsOne($tableToAggregate, $aggregated);
} else {
- $aggregated->addDataTable($tableToAggregate, $this->isAggregateSubTables());
+ $aggregated->addDataTable($tableToAggregate);
}
}
}
@@ -504,7 +493,7 @@ class ArchiveProcessor
}
foreach ($columnsToRenameAfterAggregation as $oldName => $newName) {
- $table->renameColumn($oldName, $newName, $this->isAggregateSubTables());
+ $table->renameColumn($oldName, $newName);
}
}
@@ -540,12 +529,4 @@ class ArchiveProcessor
return $metrics;
}
-
- /**
- * @return bool
- */
- protected function isAggregateSubTables()
- {
- return !$this->getParams()->isSkipAggregationOfSubTables();
- }
}
diff --git a/core/ArchiveProcessor/Parameters.php b/core/ArchiveProcessor/Parameters.php
index e51edb26a8..4edd1f4b58 100644
--- a/core/ArchiveProcessor/Parameters.php
+++ b/core/ArchiveProcessor/Parameters.php
@@ -48,12 +48,11 @@ class Parameters
*
* @ignore
*/
- public function __construct(Site $site, Period $period, Segment $segment, $skipAggregationOfSubTables = false)
+ public function __construct(Site $site, Period $period, Segment $segment)
{
$this->site = $site;
$this->period = $period;
$this->segment = $segment;
- $this->skipAggregationOfSubTables = $skipAggregationOfSubTables;
}
/**
@@ -169,11 +168,6 @@ class Parameters
return count($this->getIdSites()) == 1;
}
- public function isSkipAggregationOfSubTables()
- {
- return $this->skipAggregationOfSubTables;
- }
-
public function logStatusDebug($isTemporary)
{
$temporary = 'definitive archive';
diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php
index 1e94a046db..a715623ca6 100644
--- a/core/ArchiveProcessor/Rules.php
+++ b/core/ArchiveProcessor/Rules.php
@@ -46,13 +46,12 @@ class Rules
* @param Segment $segment
* @param string $periodLabel
* @param string $plugin
- * @param bool $isSkipAggregationOfSubTables
* @return string
*/
- public static function getDoneStringFlagFor(array $idSites, $segment, $periodLabel, $plugin, $isSkipAggregationOfSubTables)
+ public static function getDoneStringFlagFor(array $idSites, $segment, $periodLabel, $plugin)
{
if (!self::shouldProcessReportsAllPlugins($idSites, $segment, $periodLabel)) {
- return self::getDoneFlagArchiveContainsOnePlugin($segment, $plugin, $isSkipAggregationOfSubTables);
+ return self::getDoneFlagArchiveContainsOnePlugin($segment, $plugin);
}
return self::getDoneFlagArchiveContainsAllPlugins($segment);
}
@@ -83,10 +82,9 @@ class Rules
return $segmentsToProcess;
}
- public static function getDoneFlagArchiveContainsOnePlugin(Segment $segment, $plugin, $isSkipAggregationOfSubTables = false)
+ public static function getDoneFlagArchiveContainsOnePlugin(Segment $segment, $plugin)
{
- $partial = self::isFlagArchivePartial($plugin, $isSkipAggregationOfSubTables);
- return 'done' . $segment->getHash() . '.' . $plugin . $partial ;
+ return 'done' . $segment->getHash() . '.' . $plugin ;
}
private static function getDoneFlagArchiveContainsAllPlugins(Segment $segment)
@@ -95,29 +93,13 @@ class Rules
}
/**
- * @param $plugin
- * @param $isSkipAggregationOfSubTables
- * @return string
- */
- private static function isFlagArchivePartial($plugin, $isSkipAggregationOfSubTables)
- {
- $partialArchive = '';
- if ($plugin != "VisitsSummary" // VisitsSummary is always called when segmenting and should not have its own .partial archive
- && $isSkipAggregationOfSubTables
- ) {
- $partialArchive = '.partial';
- }
- return $partialArchive;
- }
-
- /**
* Return done flags used to tell how the archiving process for a specific archive was completed,
*
* @param array $plugins
* @param $segment
* @return array
*/
- public static function getDoneFlags(array $plugins, Segment $segment, $isSkipAggregationOfSubTables)
+ public static function getDoneFlags(array $plugins, Segment $segment)
{
$doneFlags = array();
$doneAllPlugins = self::getDoneFlagArchiveContainsAllPlugins($segment);
@@ -125,7 +107,7 @@ class Rules
$plugins = array_unique($plugins);
foreach ($plugins as $plugin) {
- $doneOnePlugin = self::getDoneFlagArchiveContainsOnePlugin($segment, $plugin, $isSkipAggregationOfSubTables);
+ $doneOnePlugin = self::getDoneFlagArchiveContainsOnePlugin($segment, $plugin);
$doneFlags[$plugin] = $doneOnePlugin;
}
return $doneFlags;
diff --git a/core/DataAccess/ArchiveSelector.php b/core/DataAccess/ArchiveSelector.php
index 8011924b0c..de9521d756 100644
--- a/core/DataAccess/ArchiveSelector.php
+++ b/core/DataAccess/ArchiveSelector.php
@@ -60,10 +60,9 @@ class ArchiveSelector
$requestedPlugin = $params->getRequestedPlugin();
$segment = $params->getSegment();
- $isSkipAggregationOfSubTables = $params->isSkipAggregationOfSubTables();
$plugins = array("VisitsSummary", $requestedPlugin);
- $doneFlags = Rules::getDoneFlags($plugins, $segment, $isSkipAggregationOfSubTables);
+ $doneFlags = Rules::getDoneFlags($plugins, $segment);
$doneFlagValues = Rules::getSelectableDoneFlagValues();
$results = self::getModel()->getArchiveIdAndVisits($numericTable, $idSite, $period, $dateStartIso, $dateEndIso, $minDatetimeIsoArchiveProcessedUTC, $doneFlags, $doneFlagValues);
@@ -72,8 +71,9 @@ class ArchiveSelector
return false;
}
- $idArchive = self::getMostRecentIdArchiveFromResults($segment, $requestedPlugin, $isSkipAggregationOfSubTables, $results);
- $idArchiveVisitsSummary = self::getMostRecentIdArchiveFromResults($segment, "VisitsSummary", $isSkipAggregationOfSubTables, $results);
+ $idArchive = self::getMostRecentIdArchiveFromResults($segment, $requestedPlugin, $results);
+
+ $idArchiveVisitsSummary = self::getMostRecentIdArchiveFromResults($segment, "VisitsSummary", $results);
list($visits, $visitsConverted) = self::getVisitsMetricsFromResults($idArchive, $idArchiveVisitsSummary, $results);
@@ -113,10 +113,10 @@ class ArchiveSelector
return array($visits, $visitsConverted);
}
- protected static function getMostRecentIdArchiveFromResults(Segment $segment, $requestedPlugin, $isSkipAggregationOfSubTables, $results)
+ protected static function getMostRecentIdArchiveFromResults(Segment $segment, $requestedPlugin, $results)
{
$idArchive = false;
- $namesRequestedPlugin = Rules::getDoneFlags(array($requestedPlugin), $segment, $isSkipAggregationOfSubTables);
+ $namesRequestedPlugin = Rules::getDoneFlags(array($requestedPlugin), $segment);
foreach ($results as $result) {
if ($idArchive === false
@@ -137,7 +137,6 @@ class ArchiveSelector
* @param array $periods
* @param Segment $segment
* @param array $plugins List of plugin names for which data is being requested.
- * @param bool $isSkipAggregationOfSubTables Whether we are selecting an archive that may be partial (no sub-tables)
* @return array Archive IDs are grouped by archive name and period range, ie,
* array(
* 'VisitsSummary.done' => array(
@@ -146,7 +145,7 @@ class ArchiveSelector
* )
* @throws
*/
- public static function getArchiveIds($siteIds, $periods, $segment, $plugins, $isSkipAggregationOfSubTables = false)
+ public static function getArchiveIds($siteIds, $periods, $segment, $plugins)
{
if (empty($siteIds)) {
throw new \Exception("Website IDs could not be read from the request, ie. idSite=");
@@ -155,7 +154,7 @@ class ArchiveSelector
$getArchiveIdsSql = "SELECT idsite, name, date1, date2, MAX(idarchive) as idarchive
FROM %s
WHERE idsite IN (" . Common::getSqlStringFieldsArray($siteIds) . ")
- AND " . self::getNameCondition($plugins, $segment, $isSkipAggregationOfSubTables) . "
+ AND " . self::getNameCondition($plugins, $segment) . "
AND %s
GROUP BY idsite, date1, date2";
@@ -282,14 +281,13 @@ class ArchiveSelector
*
* @param array $plugins
* @param Segment $segment
- * @param bool $isSkipAggregationOfSubTables
* @return string
*/
- private static function getNameCondition(array $plugins, Segment $segment, $isSkipAggregationOfSubTables)
+ private static function getNameCondition(array $plugins, Segment $segment)
{
// the flags used to tell how the archiving process for a specific archive was completed,
// if it was completed
- $doneFlags = Rules::getDoneFlags($plugins, $segment, $isSkipAggregationOfSubTables);
+ $doneFlags = Rules::getDoneFlags($plugins, $segment);
$allDoneFlags = "'" . implode("','", $doneFlags) . "'";
$possibleValues = Rules::getSelectableDoneFlagValues();
diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php
index 1fcacf790d..32943ceeb4 100644
--- a/core/DataAccess/ArchiveWriter.php
+++ b/core/DataAccess/ArchiveWriter.php
@@ -67,7 +67,7 @@ class ArchiveWriter
$this->period = $params->getPeriod();
$idSites = array($this->idSite);
- $this->doneFlag = Rules::getDoneStringFlagFor($idSites, $this->segment, $this->period->getLabel(), $params->getRequestedPlugin(), $params->isSkipAggregationOfSubTables());
+ $this->doneFlag = Rules::getDoneStringFlagFor($idSites, $this->segment, $this->period->getLabel(), $params->getRequestedPlugin());
$this->isArchiveTemporary = $isArchiveTemporary;
$this->dateStart = $this->period->getDateStart();
diff --git a/core/DataTable.php b/core/DataTable.php
index 895645af0f..b060a87245 100644
--- a/core/DataTable.php
+++ b/core/DataTable.php
@@ -477,10 +477,9 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
* metadata can be used to specify a different type of operation.
*
* @param \Piwik\DataTable $tableToSum
- * @param bool $doAggregateSubTables
* @throws Exception
*/
- public function addDataTable(DataTable $tableToSum, $doAggregateSubTables = true)
+ public function addDataTable(DataTable $tableToSum)
{
if ($tableToSum instanceof Simple) {
if ($tableToSum->getRowsCount() > 1) {
@@ -490,7 +489,7 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
$this->aggregateRowFromSimpleTable($row);
} else {
foreach ($tableToSum->getRows() as $row) {
- $this->aggregateRowWithLabel($row, $doAggregateSubTables);
+ $this->aggregateRowWithLabel($row);
}
}
}
@@ -902,16 +901,14 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
* @param string $oldName Old column name.
* @param string $newName New column name.
*/
- public function renameColumn($oldName, $newName, $doRenameColumnsOfSubTables = true)
+ public function renameColumn($oldName, $newName)
{
foreach ($this->getRows() as $row) {
$row->renameColumn($oldName, $newName);
- if ($doRenameColumnsOfSubTables) {
- $subTable = $row->getSubtable();
- if ($subTable) {
- $subTable->renameColumn($oldName, $newName);
- }
+ $subTable = $row->getSubtable();
+ if ($subTable) {
+ $subTable->renameColumn($oldName, $newName);
}
}
if (!is_null($this->summaryRow)) {
@@ -1591,7 +1588,7 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
* @param $row
* @throws \Exception
*/
- protected function aggregateRowWithLabel(Row $row, $doAggregateSubTables = true)
+ protected function aggregateRowWithLabel(Row $row)
{
$labelToLookFor = $row->getColumn('label');
if ($labelToLookFor === false) {
@@ -1607,17 +1604,15 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
} else {
$rowFound->sumRow($row, $copyMeta = true, $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME));
- if ($doAggregateSubTables) {
- // if the row to add has a subtable whereas the current row doesn't
- // we simply add it (cloning the subtable)
- // if the row has the subtable already
- // then we have to recursively sum the subtables
- $subTable = $row->getSubtable();
- if ($subTable) {
- $subTable->metadata[self::COLUMN_AGGREGATION_OPS_METADATA_NAME]
- = $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
- $rowFound->sumSubtable($subTable);
- }
+ // if the row to add has a subtable whereas the current row doesn't
+ // we simply add it (cloning the subtable)
+ // if the row has the subtable already
+ // then we have to recursively sum the subtables
+ $subTable = $row->getSubtable();
+ if ($subTable) {
+ $subTable->metadata[self::COLUMN_AGGREGATION_OPS_METADATA_NAME]
+ = $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
+ $rowFound->sumSubtable($subTable);
}
}
}