diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-08-13 18:19:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-13 18:19:45 +0300 |
commit | b555e1c613b0f674d86a44850fa5907c613b8e35 (patch) | |
tree | 54edd15bb4841bc60994700f33c4f511c12f001e /plugins | |
parent | 732b8059736153cceb4c230e59e498bd1ab4bb0c (diff) |
Use a stable sort method for visited pages in user profile (#13284)
* Use a stable stort method for visited pages in user profile
* update tests
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Actions/VisitorDetails.php | 9 | ||||
-rw-r--r-- | plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/plugins/Actions/VisitorDetails.php b/plugins/Actions/VisitorDetails.php index b770c5ac4c..d6b5ecfff8 100644 --- a/plugins/Actions/VisitorDetails.php +++ b/plugins/Actions/VisitorDetails.php @@ -266,7 +266,6 @@ class VisitorDetails extends VisitorDetailsAbstract public function finalizeProfile($visits, &$profile) { - arsort($this->visitedPageUrls); $profile['visitedPages'] = []; foreach ($this->visitedPageUrls as $visitedPageUrl => $count) { @@ -276,6 +275,14 @@ class VisitorDetails extends VisitorDetailsAbstract ]; } + usort($profile['visitedPages'], function($a, $b) { + if ($a['count'] == $b['count']) { + return strcmp($a['url'], $b['url']); + } + + return strcmp($b['count'], $a['count']); + }); + $this->handleSiteSearches($profile); $this->handleAveragePageGenerationTime($profile); } diff --git a/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml b/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml index c74092bf7a..3e62cb9f09 100644 --- a/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml +++ b/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml @@ -1224,10 +1224,6 @@ <visitsAggregated>10</visitsAggregated> <visitedPages> <row> - <url>http://example.org/my/dir/page3</url> - <count>5</count> - </row> - <row> <url>http://example.org/my/dir/page0</url> <count>5</count> </row> @@ -1239,6 +1235,10 @@ <url>http://example.org/my/dir/page2</url> <count>5</count> </row> + <row> + <url>http://example.org/my/dir/page3</url> + <count>5</count> + </row> </visitedPages> <devices> <row> |