diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-08-07 00:16:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-07 00:16:13 +0300 |
commit | 8bc18861652ddcd64f8022318f0b8201ac7e9ba4 (patch) | |
tree | 73e65f15b3467cf8a3bd048bfba432c356ed85ba /plugins | |
parent | be4540fd4c15118bf773683d6c7848b22af903a1 (diff) |
Handle ranking query others row properly in contents & events archiver. (#14622)
* Add more types of actions to ManyVisitsWithMockLocationProvider fixture.
* fix test change
* update expected test files
* Handle ranking query others row properly in contents & events archiver.
* Use custom ranking query specific others label and handle by default in DataArray::asDatatable().
* Updating expected test files.
* Use strict compare since label can be 0 apparently.
* Update expecred test files.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/API/tests/System/expected/test_AutoSuggestAPITest__Live.getLastVisitsDetails_range.xml | 4 | ||||
-rw-r--r-- | plugins/Actions/Archiver.php | 4 | ||||
-rw-r--r-- | plugins/Actions/ArchivingHelper.php | 7 | ||||
-rw-r--r-- | plugins/Contents/Archiver.php | 2 | ||||
-rw-r--r-- | plugins/Events/Archiver.php | 1 | ||||
-rw-r--r-- | plugins/Transitions/API.php | 3 | ||||
-rw-r--r-- | plugins/UserId/Archiver.php | 16 |
7 files changed, 9 insertions, 28 deletions
diff --git a/plugins/API/tests/System/expected/test_AutoSuggestAPITest__Live.getLastVisitsDetails_range.xml b/plugins/API/tests/System/expected/test_AutoSuggestAPITest__Live.getLastVisitsDetails_range.xml index 30e2003c77..88cb9a1057 100644 --- a/plugins/API/tests/System/expected/test_AutoSuggestAPITest__Live.getLastVisitsDetails_range.xml +++ b/plugins/API/tests/System/expected/test_AutoSuggestAPITest__Live.getLastVisitsDetails_range.xml @@ -2581,7 +2581,7 @@ <region>Xizang Zizhiqu</region> <regionCode>XZ</regionCode> <city>Lhasa</city> - <location>Lhasa, Xizang, China</location> + <location>Lhasa, Xizang Zizhiqu, China</location> <latitude>29.650000</latitude> <longitude>91.100000</longitude> <visitLocalTime>12:34:06</visitLocalTime> @@ -2883,7 +2883,7 @@ <region>Xizang Zizhiqu</region> <regionCode>XZ</regionCode> <city>Lhasa</city> - <location>Lhasa, Xizang, China</location> + <location>Lhasa, Xizang Zizhiqu, China</location> <latitude>29.650000</latitude> <longitude>91.100000</longitude> <visitLocalTime>12:34:06</visitLocalTime> diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php index ddb05cc5ae..35ecf41230 100644 --- a/plugins/Actions/Archiver.php +++ b/plugins/Actions/Archiver.php @@ -200,7 +200,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn(array('idaction', 'name')); $rankingQuery->addColumn('url_prefix'); @@ -281,7 +280,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_ENTRY_NB_UNIQ_VISITORS); $rankingQuery->addColumn(array(PiwikMetrics::INDEX_PAGE_ENTRY_NB_VISITS, @@ -330,7 +328,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS); $rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_EXIT_NB_VISITS, 'sum'); @@ -374,7 +371,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_SUM_TIME_SPENT, 'sum'); $rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($this->actionsTablesByType)); diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php index 2e878a45bb..e5c315d0b1 100644 --- a/plugins/Actions/ArchivingHelper.php +++ b/plugins/Actions/ArchivingHelper.php @@ -15,6 +15,7 @@ use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Metrics as PiwikMetrics; use Piwik\Piwik; +use Piwik\RankingQuery; use Piwik\Tracker\Action; use Piwik\Tracker\PageUrl; use Zend_Db_Statement; @@ -57,7 +58,7 @@ class ArchivingHelper continue; } - $hasRowName = !empty($row['name']) && $row['name'] != DataTable::LABEL_SUMMARY_ROW; + $hasRowName = !empty($row['name']) && $row['name'] != RankingQuery::LABEL_SUMMARY_ROW; // This will appear as <url /> in the API, which is actually very important to keep // eg. When there's at least one row in a report that does not have a URL, not having this <url/> would break HTML/PDF reports. @@ -381,7 +382,7 @@ class ArchivingHelper } // check for ranking query cut-off - if ($actionName == DataTable::LABEL_SUMMARY_ROW) { + if ($actionName == RankingQuery::LABEL_SUMMARY_ROW) { $summaryRow = $currentTable->getRowFromId(DataTable::ID_SUMMARY_ROW); if ($summaryRow === false) { $summaryRow = $currentTable->addSummaryRow(self::createSummaryRow()); @@ -499,7 +500,7 @@ class ArchivingHelper */ private static function getCachedActionRowKey($idAction, $actionType) { - return $idAction == DataTable::LABEL_SUMMARY_ROW + return $idAction == RankingQuery::LABEL_SUMMARY_ROW ? $actionType . '_others' : $idAction; } diff --git a/plugins/Contents/Archiver.php b/plugins/Contents/Archiver.php index 27ead44c37..a627ac38d8 100644 --- a/plugins/Contents/Archiver.php +++ b/plugins/Contents/Archiver.php @@ -117,7 +117,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = null; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn(array('contentPiece', 'contentTarget', 'contentName')); $rankingQuery->addColumn(array(Metrics::INDEX_NB_UNIQ_VISITORS)); $rankingQuery->addColumn(array(Metrics::INDEX_CONTENT_NB_IMPRESSIONS, Metrics::INDEX_NB_VISITS), 'sum'); @@ -173,7 +172,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = null; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn(array('contentPiece', 'contentInteraction', 'contentName')); $rankingQuery->addColumn(array(Metrics::INDEX_CONTENT_NB_INTERACTIONS), 'sum'); } diff --git a/plugins/Events/Archiver.php b/plugins/Events/Archiver.php index bfa4813e36..b87ff8543a 100644 --- a/plugins/Events/Archiver.php +++ b/plugins/Events/Archiver.php @@ -180,7 +180,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = null; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn(array('eventCategory', 'eventAction', 'eventName')); $rankingQuery->addColumn(array(Metrics::INDEX_NB_UNIQ_VISITORS)); $rankingQuery->addColumn(array(Metrics::INDEX_EVENT_NB_HITS, Metrics::INDEX_NB_VISITS, Metrics::INDEX_EVENT_NB_HITS_WITH_VALUE), 'sum'); diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php index 4c57d2722d..33c330f999 100644 --- a/plugins/Transitions/API.php +++ b/plugins/Transitions/API.php @@ -271,6 +271,7 @@ class API extends \Piwik\Plugin\API $types[Action::TYPE_DOWNLOAD] = 'downloads'; $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery->setOthersLabel('Others'); $rankingQuery->addLabelColumn(array('name', 'url_prefix')); $rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($types)); @@ -301,6 +302,7 @@ class API extends \Piwik\Plugin\API protected function queryExternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = false) { $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery->setOthersLabel('Others'); // we generate a single column that contains the interesting data for each referrer. // the reason we cannot group by referer_* becomes clear when we look at search engine keywords. @@ -379,6 +381,7 @@ class API extends \Piwik\Plugin\API $keyIsSiteSearchAction = 2; $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery->setOthersLabel('Others'); $rankingQuery->addLabelColumn(array('name', 'url_prefix')); $rankingQuery->setColumnToMarkExcludedRows('is_self'); $rankingQuery->partitionResultIntoMultipleGroups('action_partition', array($keyIsOther, $keyIsPageUrlAction, $keyIsSiteSearchAction)); diff --git a/plugins/UserId/Archiver.php b/plugins/UserId/Archiver.php index ae7fdcee8a..07e6be51d5 100644 --- a/plugins/UserId/Archiver.php +++ b/plugins/UserId/Archiver.php @@ -83,7 +83,6 @@ class Archiver extends \Piwik\Plugin\Archiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn($userIdFieldName); $rankingQuery->addLabelColumn($visitorIdFieldName); } @@ -119,21 +118,6 @@ class Archiver extends \Piwik\Plugin\Archiver { /** @var DataTable $dataTable */ $dataTable = $this->arrays->asDataTable(); - - // deal w/ ranking query summary row - $rankingQuerySummaryRow = $dataTable->getRowFromLabel(DataTable::LABEL_SUMMARY_ROW); - if ($rankingQuerySummaryRow) { - $rankingQuerySummaryRowId = $dataTable->getRowIdFromLabel(DataTable::LABEL_SUMMARY_ROW); - $dataTable->deleteRow($rankingQuerySummaryRowId); - - $actualSummaryRow = $dataTable->getRowFromId(DataTable::ID_SUMMARY_ROW); - if ($actualSummaryRow) { - $actualSummaryRow->sumRow($rankingQuerySummaryRow); - } else { - $dataTable->addSummaryRow($rankingQuerySummaryRow); - } - } - $this->setVisitorIds($dataTable); $report = $dataTable->getSerialized($this->maximumRowsInDataTableLevelZero, null, PiwikMetrics::INDEX_NB_VISITS); $this->getProcessor()->insertBlobRecord(self::USERID_ARCHIVE_RECORD, $report); |