Skip to content
Extraits de code Groupes Projets
Valider b53839f7 rédigé par mattab's avatar mattab
Parcourir les fichiers

removing destroy() calls

parent a701d4a4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -19,6 +19,7 @@ abstract class Piwik_PluginsArchiver
public function __construct(Piwik_ArchiveProcessing $processing)
{
$this->maximumRows = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_standard'];
$this->processor = $processing;
}
......
......@@ -411,49 +411,37 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver
{
Piwik_Actions_ArchivingHelper::clearActionsCache();
/** @var Piwik_DataTable $dataTable */
$dataTable = $this->actionsTablesByType[Piwik_Tracker_Action::TYPE_ACTION_URL];
self::deleteInvalidSummedColumnsFromDataTable($dataTable);
$s = $dataTable->getSerialized(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero, Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable, Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord('Actions_actions_url', $s);
$this->recordPageUrlsReports();
$this->recordDownloadsReports();
$this->recordOutlinksReports();
$this->recordPageTitlesReports();
$this->recordSiteSearchReports();
}
protected function recordPageUrlsReports()
{
$dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_ACTION_URL);
$this->recordDataTable($dataTable, 'Actions_actions_url');
$this->getProcessor()->insertNumericRecord('Actions_nb_pageviews', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_PAGE_NB_HITS)));
$this->getProcessor()->insertNumericRecord('Actions_nb_uniq_pageviews', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS)));
$this->getProcessor()->insertNumericRecord('Actions_sum_time_generation', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_PAGE_SUM_TIME_GENERATION)));
$this->getProcessor()->insertNumericRecord('Actions_nb_hits_with_time_generation', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION)));
destroy($dataTable);
$dataTable = $this->actionsTablesByType[Piwik_Tracker_Action::TYPE_DOWNLOAD];
self::deleteInvalidSummedColumnsFromDataTable($dataTable);
$s = $dataTable->getSerialized(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero, Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable, Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord('Actions_downloads', $s);
$this->getProcessor()->insertNumericRecord('Actions_nb_downloads', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_PAGE_NB_HITS)));
$this->getProcessor()->insertNumericRecord('Actions_nb_uniq_downloads', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS)));
destroy($dataTable);
$dataTable = $this->actionsTablesByType[Piwik_Tracker_Action::TYPE_OUTLINK];
self::deleteInvalidSummedColumnsFromDataTable($dataTable);
$s = $dataTable->getSerialized(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero, Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable, Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord('Actions_outlink', $s);
$this->getProcessor()->insertNumericRecord('Actions_nb_outlinks', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_PAGE_NB_HITS)));
$this->getProcessor()->insertNumericRecord('Actions_nb_uniq_outlinks', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS)));
destroy($dataTable);
}
$dataTable = $this->actionsTablesByType[Piwik_Tracker_Action::TYPE_ACTION_NAME];
self::deleteInvalidSummedColumnsFromDataTable($dataTable);
$s = $dataTable->getSerialized(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero, Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable, Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord('Actions_actions', $s);
destroy($dataTable);
/**
* @param $typeId
* @return Piwik_DataTable
*/
protected function getDataTable($typeId)
{
return $this->actionsTablesByType[$typeId];
}
$dataTable = $this->actionsTablesByType[Piwik_Tracker_Action::TYPE_SITE_SEARCH];
protected function recordDataTable($dataTable, $recordName)
{
self::deleteInvalidSummedColumnsFromDataTable($dataTable);
$this->deleteUnusedColumnsFromKeywordsDataTable($dataTable);
$s = $dataTable->getSerialized(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero, Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable, Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord('Actions_sitesearch', $s);
$this->getProcessor()->insertNumericRecord('Actions_nb_searches', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS)));
$this->getProcessor()->insertNumericRecord('Actions_nb_keywords', $dataTable->getRowsCount());
destroy($dataTable);
destroy($this->actionsTablesByType);
$this->getProcessor()->insertBlobRecord($recordName, $s);
}
/**
......@@ -497,6 +485,40 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver
));
}
protected function recordDownloadsReports()
{
$dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_DOWNLOAD);
$this->recordDataTable($dataTable, 'Actions_downloads');
$this->getProcessor()->insertNumericRecord('Actions_nb_downloads', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_PAGE_NB_HITS)));
$this->getProcessor()->insertNumericRecord('Actions_nb_uniq_downloads', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS)));
}
protected function recordOutlinksReports()
{
$dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_OUTLINK);
$this->recordDataTable($dataTable, 'Actions_outlink');
$this->getProcessor()->insertNumericRecord('Actions_nb_outlinks', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_PAGE_NB_HITS)));
$this->getProcessor()->insertNumericRecord('Actions_nb_uniq_outlinks', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS)));
}
protected function recordPageTitlesReports()
{
$dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_ACTION_NAME);
$this->recordDataTable($dataTable, 'Actions_actions');
}
protected function recordSiteSearchReports()
{
$dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_SITE_SEARCH);
$this->deleteUnusedColumnsFromKeywordsDataTable($dataTable);
$this->recordDataTable($dataTable, 'Actions_sitesearch');
$this->getProcessor()->insertNumericRecord('Actions_nb_searches', array_sum($dataTable->getColumn(Piwik_Archive::INDEX_NB_VISITS)));
$this->getProcessor()->insertNumericRecord('Actions_nb_keywords', $dataTable->getRowsCount());
}
protected function deleteUnusedColumnsFromKeywordsDataTable($dataTable)
{
$columnsToDelete = array(
......
......@@ -23,6 +23,8 @@ class Piwik_UserCountry_Archiver extends Piwik_PluginsArchiver
private $metricsByDimension = array();
protected $maximumRows;
public function archiveDay()
{
$this->metricsByDimension = array('location_country' => array(),
......@@ -145,23 +147,19 @@ class Piwik_UserCountry_Archiver extends Piwik_PluginsArchiver
protected function recordDayReports()
{
$maximumRows = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_standard'];
$tableCountry = Piwik_ArchiveProcessing_Day::getDataTableFromArray($this->metricsByDimension['location_country']);
$this->getProcessor()->insertBlobRecord(self::VISITS_BY_COUNTRY_RECORD_NAME, $tableCountry->getSerialized());
$this->getProcessor()->insertNumericRecord(self::DISTINCT_COUNTRIES_METRIC, $tableCountry->getRowsCount());
destroy($tableCountry);
$tableRegion = Piwik_ArchiveProcessing_Day::getDataTableFromArray($this->metricsByDimension['location_region']);
$serialized = $tableRegion->getSerialized($maximumRows, $maximumRows, Piwik_Archive::INDEX_NB_VISITS);
$serialized = $tableRegion->getSerialized($this->maximumRows, $this->maximumRows, Piwik_Archive::INDEX_NB_VISITS);
$this->getProcessor()->insertBlobRecord(self::VISITS_BY_REGION_RECORD_NAME, $serialized);
destroy($tableRegion);
$tableCity = Piwik_ArchiveProcessing_Day::getDataTableFromArray($this->metricsByDimension['location_city']);
$this->setLatitudeLongitude($tableCity);
$serialized = $tableCity->getSerialized($maximumRows, $maximumRows, Piwik_Archive::INDEX_NB_VISITS);
$serialized = $tableCity->getSerialized($this->maximumRows, $this->maximumRows, Piwik_Archive::INDEX_NB_VISITS);
$this->getProcessor()->insertBlobRecord(self::VISITS_BY_CITY_RECORD_NAME, $serialized);
destroy($tableCity);
}
/**
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter