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:
authorKate Butler <kate@innocraft.com>2019-04-05 20:13:58 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-04-05 20:13:58 +0300
commit3140f5a4112796a6ec32593b3cde28d970beca58 (patch)
tree957823a9c5ce1961b1de82558d978333aec2fba3 /plugins/Actions
parent062eeb0cfa3fb9e4aa0930822a86996b55422b5a (diff)
Add new config datatable_archiving_maximum_rows_site_search (#14112)
* Add new config datatable_archiving_maximum_rows_site_search to control number of rows archived for site search * Fix hardcoding * Use new datatable_archiving_maximum_rows_site_search query limit for archiveDayActions() only * Split site search archiving out into a separate query * Fix page actions archiving query * Fix broken unit tests * Fix broken unit tests * Refactoring * Unit test for new datatable_archiving_maximum_rows_site_search config setting * Comments
Diffstat (limited to 'plugins/Actions')
-rw-r--r--plugins/Actions/Archiver.php43
-rw-r--r--plugins/Actions/ArchivingHelper.php2
2 files changed, 40 insertions, 5 deletions
diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php
index 4b0dd46116..5bf1fa0ba6 100644
--- a/plugins/Actions/Archiver.php
+++ b/plugins/Actions/Archiver.php
@@ -58,7 +58,9 @@ class Archiver extends \Piwik\Plugin\Archiver
ArchivingHelper::reloadConfig();
$this->initActionsTables();
- $this->archiveDayActions($rankingQueryLimit);
+
+ $this->archiveDayPageActions($rankingQueryLimit);
+ $this->archiveDaySiteSearchActions($rankingQueryLimit);
$this->archiveDayEntryActions($rankingQueryLimit);
$this->archiveDayExitActions($rankingQueryLimit);
$this->archiveDayActionsTime($rankingQueryLimit);
@@ -130,7 +132,12 @@ class Archiver extends \Piwik\Plugin\Archiver
$this->actionsTablesByType = array();
foreach (Metrics::$actionTypes as $type) {
$dataTable = new DataTable();
- $dataTable->setMaximumAllowedRows(ArchivingHelper::$maximumRowsInDataTableLevelZero);
+ if ($type === Action::TYPE_SITE_SEARCH) {
+ $maxRows = ArchivingHelper::$maximumRowsInDataTableSiteSearch;
+ } else {
+ $maxRows = ArchivingHelper::$maximumRowsInDataTableLevelZero;
+ }
+ $dataTable->setMaximumAllowedRows($maxRows);
if ($type == Action::TYPE_PAGE_URL
|| $type == Action::TYPE_PAGE_TITLE
@@ -143,7 +150,22 @@ class Archiver extends \Piwik\Plugin\Archiver
}
}
- protected function archiveDayActions($rankingQueryLimit)
+ protected function archiveDayPageActions($rankingQueryLimit)
+ {
+ $typesToQuery = $this->actionsTablesByType;
+ unset($typesToQuery[Action::TYPE_SITE_SEARCH]);
+ $this->archiveDayActions($rankingQueryLimit, array_keys($typesToQuery), true);
+ }
+
+ protected function archiveDaySiteSearchActions($rankingQueryLimit)
+ {
+ if ($this->isSiteSearchEnabled()) {
+ $rankingQueryLimit = max($rankingQueryLimit, ArchivingHelper::$maximumRowsInDataTableSiteSearch);
+ $this->archiveDayActions($rankingQueryLimit, array(Action::TYPE_SITE_SEARCH), false);
+ }
+ }
+
+ protected function archiveDayActions($rankingQueryLimit, array $actionTypes, $includePageNotDefined)
{
$metricsConfig = Metrics::getActionMetrics();
@@ -166,6 +188,12 @@ class Archiver extends \Piwik\Plugin\Archiver
$where .= " AND log_link_visit_action.%s IS NOT NULL"
. $this->getWhereClauseActionIsNotEvent();
+ $actionTypesWhere = "log_action.type IN (" . implode(", ", $actionTypes) . ")";
+ if ($includePageNotDefined) {
+ $actionTypesWhere = "(" . $actionTypesWhere . " OR log_action.type IS NULL)";
+ }
+ $where .= " AND $actionTypesWhere";
+
$groupBy = "log_link_visit_action.%s";
$orderBy = "`" . PiwikMetrics::INDEX_PAGE_NB_HITS . "` DESC, name ASC";
@@ -183,7 +211,7 @@ class Archiver extends \Piwik\Plugin\Archiver
$this->addMetricsToRankingQuery($rankingQuery, $metricsConfig);
- $rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($this->actionsTablesByType));
+ $rankingQuery->partitionResultIntoMultipleGroups('type', $actionTypes);
}
// Special Magic to get
@@ -426,7 +454,12 @@ class Archiver extends \Piwik\Plugin\Archiver
protected function insertTable(DataTable $dataTable, $recordName)
{
ArchivingHelper::deleteInvalidSummedColumnsFromDataTable($dataTable);
- $report = $dataTable->getSerialized(ArchivingHelper::$maximumRowsInDataTableLevelZero, ArchivingHelper::$maximumRowsInSubDataTable, ArchivingHelper::$columnToSortByBeforeTruncation);
+ if ($recordName === Archiver::SITE_SEARCH_RECORD_NAME) {
+ $maxRows = ArchivingHelper::$maximumRowsInDataTableSiteSearch;
+ } else {
+ $maxRows = ArchivingHelper::$maximumRowsInDataTableLevelZero;
+ }
+ $report = $dataTable->getSerialized($maxRows, ArchivingHelper::$maximumRowsInSubDataTable, ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord($recordName, $report);
}
diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php
index 0570fce999..aa1aa3cbae 100644
--- a/plugins/Actions/ArchivingHelper.php
+++ b/plugins/Actions/ArchivingHelper.php
@@ -307,6 +307,7 @@ class ArchivingHelper
public static $maximumRowsInDataTableLevelZero;
public static $maximumRowsInSubDataTable;
+ public static $maximumRowsInDataTableSiteSearch;
public static $columnToSortByBeforeTruncation;
protected static $actionUrlCategoryDelimiter = null;
@@ -330,6 +331,7 @@ class ArchivingHelper
self::$columnToSortByBeforeTruncation = PiwikMetrics::INDEX_NB_VISITS;
self::$maximumRowsInDataTableLevelZero = Config::getInstance()->General['datatable_archiving_maximum_rows_actions'];
self::$maximumRowsInSubDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_actions'];
+ self::$maximumRowsInDataTableSiteSearch = Config::getInstance()->General['datatable_archiving_maximum_rows_site_search'];
DataTable::setMaximumDepthLevelAllowedAtLeast(self::getSubCategoryLevelLimit() + 1);
}