diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-01-30 23:44:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 23:44:41 +0300 |
commit | 3b836fa9e583713628e227d7bd86388ec8e2638b (patch) | |
tree | 0d4ee8917e9b5d4d5950651723ca871626b4279f /plugins | |
parent | aeb7aa31a44ab422336523576a27f15559922c9f (diff) |
Trying to fix randomly failing tests (#15461)
Diffstat (limited to 'plugins')
13 files changed, 77 insertions, 41 deletions
diff --git a/plugins/Actions/tests/UI/expected-screenshots/ActionsDataTable_segmented_visitor_log.png b/plugins/Actions/tests/UI/expected-screenshots/ActionsDataTable_segmented_visitor_log.png index e22bcfa90b..5594398ca2 100644 --- a/plugins/Actions/tests/UI/expected-screenshots/ActionsDataTable_segmented_visitor_log.png +++ b/plugins/Actions/tests/UI/expected-screenshots/ActionsDataTable_segmented_visitor_log.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d866e324e519af5ca51351bc5fbf7eddc0f8ff9f8edc94c6a9ef227ca1896a7e -size 381898 +oid sha256:401ff0f9327b2e2800ed3e79a18d3a91b1697f8f7be3d10a0a028821635fed19 +size 381984 diff --git a/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png b/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png index 7034b1ad1c..2dd8c4dc43 100644 --- a/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png +++ b/plugins/Dashboard/tests/UI/expected-screenshots/DashboardManager_removed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:81f81764ba472da0f4ee6484b0bd3b1d011f900ff55754ec5401e3ce1aacb3a2 -size 470588 +oid sha256:4a7714eb47d44749f1186072224763e568fa6e0a0d750e6fd9dfe3ea7dd8c80e +size 470401 diff --git a/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_loaded_token_auth.png b/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_loaded_token_auth.png index 02a206391a..53eccc51ba 100644 --- a/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_loaded_token_auth.png +++ b/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_loaded_token_auth.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:02b3b9b3ceac06edb4b82344a3160edc81c8e095468f1b617590cbd660df4187 -size 714992 +oid sha256:ea8954c9b69f59fe06edb66b9959f3b826786f58f84367bc6a0bab15f67715d2 +size 714817 diff --git a/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_removed.png b/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_removed.png index 02a206391a..53eccc51ba 100644 --- a/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_removed.png +++ b/plugins/Dashboard/tests/UI/expected-screenshots/Dashboard_removed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:02b3b9b3ceac06edb4b82344a3160edc81c8e095468f1b617590cbd660df4187 -size 714992 +oid sha256:ea8954c9b69f59fe06edb66b9959f3b826786f58f84367bc6a0bab15f67715d2 +size 714817 diff --git a/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png b/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png index 38c620ea39..b8e3ba75eb 100644 --- a/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png +++ b/plugins/Diagnostics/tests/UI/expected-screenshots/Diagnostics_page.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:beac9c4490143385645ba9176a3cb52dc32ce1c46cffd34d4dee642449dd36b2 -size 204429 +oid sha256:cba4af1a42ee5eb213da15eabc299795af4054ca8a914ffd1141cb80480c7787 +size 204228 diff --git a/plugins/Feedback/tests/UI/expected-screenshots/FeedbackPopup_dashboard_no_popup.png b/plugins/Feedback/tests/UI/expected-screenshots/FeedbackPopup_dashboard_no_popup.png index 6e878672ff..58cfb5aacf 100644 --- a/plugins/Feedback/tests/UI/expected-screenshots/FeedbackPopup_dashboard_no_popup.png +++ b/plugins/Feedback/tests/UI/expected-screenshots/FeedbackPopup_dashboard_no_popup.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc374ffc11060b8c12ae60f494e66dc371b64946d807c929eeb32166f2d04938 -size 409334 +oid sha256:44c97885caf1a5e6148023cfcd323ad51415e0eabac3e08f7e91f1da6a93b6a1 +size 409180 diff --git a/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png b/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png index e99e20e72d..6f1ff436ee 100644 --- a/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png +++ b/plugins/Installation/tests/UI/expected-screenshots/Installation_system_check.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a3beb1da8948e1972a9833678fa1eae8db3179f8b37d3404dbef227a66ec168b -size 188875 +oid sha256:8b76e58a10a6ce2cb33ae718186e7f55acf28bbe1d1254cbb0d03cf410e14465 +size 188679 diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index 99ff282848..fc2d29b3b0 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -16,6 +16,7 @@ use Piwik\Date; use Piwik\Metrics\Formatter; use Piwik\Plugin; use Piwik\Piwik; +use Piwik\Plugins\Live\Visualizations\VisitorLog; use Piwik\Tracker\GoalManager; class Visitor implements VisitorInterface @@ -291,7 +292,7 @@ class Visitor implements VisitorInterface $instance->filterActions($actionDetails, $visitorDetailsArray); } - usort($actionDetails, array('static', 'sortByServerTime')); + $actionDetails = self::sortActionDetails($actionDetails); $actionDetails = array_values($actionDetails); @@ -315,27 +316,21 @@ class Visitor implements VisitorInterface return $visitorDetailsArray; } - private static function sortByServerTime($a, $b) + private static function sortActionDetails($actions) { - $ta = strtotime($a['serverTimePretty']); - $tb = strtotime($b['serverTimePretty']); - - if ($ta < $tb) { - return -1; - } - - if ($ta == $tb) { - if ($a['idlink_va'] == $b['idlink_va']) { - return strcmp($a['type'], $b['type']); - } - - if ($a['idlink_va'] > $b['idlink_va']) { - return 1; + usort($actions, function ($a, $b) { + $fields = array('serverTimePretty', 'idlink_va', 'type', 'title', 'url', 'pageIdAction', 'goalId'); + foreach ($fields as $field) { + $sort = VisitorLog::sortByActionsOnPageColumn($a, $b, $field); + if ($sort !== 0) { + return $sort; + } } - return -1; - } + return 0; + }); - return 1; + return $actions; } + } diff --git a/plugins/Live/Visualizations/VisitorLog.php b/plugins/Live/Visualizations/VisitorLog.php index 31c0efcd9e..d6c3cd08a2 100644 --- a/plugins/Live/Visualizations/VisitorLog.php +++ b/plugins/Live/Visualizations/VisitorLog.php @@ -202,6 +202,23 @@ class VisitorLog extends Visualization } } + foreach ($actionGroups as $idPageView => $actionGroup) { + if (!empty($actionGroup['actionsOnPage'])) { + usort($actionGroup['actionsOnPage'], function ($a, $b) { + $fields = array('timestamp', 'title', 'url', 'type', 'pageIdAction', 'goalId', 'timeSpent'); + foreach ($fields as $field) { + $sort = self::sortByActionsOnPageColumn($a, $b, $field); + if ($sort !== 0) { + return $sort; + } + } + + return 0; + }); + $actionGroups[$idPageView]['actionsOnPage'] = $actionGroup['actionsOnPage']; + } + } + // merge action groups that have the same page url/action and no pageviewactions $actionGroups = self::mergeRefreshes($actionGroups); @@ -209,6 +226,30 @@ class VisitorLog extends Visualization } } + public static function sortByActionsOnPageColumn($a, $b, $field) + { + if (!isset($a[$field]) && !isset($b[$field])) { + return 0; + } + if (!isset($a[$field])) { + return -1; + } + if (!isset($b[$field])) { + return 1; + } + if ($field === 'serverTimePretty') { + $a[$field] = strtotime($a[$field]); + $b[$field] = strtotime($b[$field]); + } + if ($a[$field] === $b[$field]) { + return 0; + } + if ($a[$field] < $b[$field]) { + return -1; + } + return 1; + } + private static function mergeRefreshes(array $actionGroups) { $previousId = null; diff --git a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log.png b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log.png index e556fb1ffd..1128675542 100644 --- a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log.png +++ b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3dbbfb7280b58c59197ae791c14fa7b4dcf40a4d868bd9ef77614055b05f199 -size 386906 +oid sha256:363ee1f7abca91be5422910989a2328cfc507f217d2eaf1008b8bd7862c49d1a +size 386911 diff --git a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log_expand_pageview_actions.png b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log_expand_pageview_actions.png index 1b98f667be..bca3118156 100644 --- a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log_expand_pageview_actions.png +++ b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_log_expand_pageview_actions.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:952d7e1a73a09d164f7d2b1acf83768b4d42159c46a3d11eb767d7fcd190864f -size 102198 +oid sha256:c7b27fe264d6b12a0383fe1e788c43d7544dbc7d8cd94752bedc56b081757804 +size 102195 diff --git a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile.png b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile.png index d181af2d47..3361725e7d 100644 --- a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile.png +++ b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ac1caaa7a88f52c057c4d5331b9761a5d363a6e20f2809d60c1524461611af5 -size 418479 +oid sha256:9ca0fcc3ee5901df974c348fd7da020df9f4283bfd5768eba89b664717272000 +size 418489 diff --git a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile_limited.png b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile_limited.png index 8fea3c44f2..d46830adc0 100644 --- a/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile_limited.png +++ b/plugins/Live/tests/UI/expected-screenshots/Live_visitor_profile_limited.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:23ab3a8404d0c0fdc67fd30720968a7ba1f062e8b485f737c8894d0bc45b586b -size 310449 +oid sha256:81d25e5b1ecdd3bd0d094fccab4b387a1e00d147015b5621a68942edc2e65113 +size 310462 |