{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments/28928538","id":28928538,"diff_hunk":"@@ -184,12 +184,24 @@ treeherder.factory('thNotify', [\n             $log.debug(\"received message\", message);\n             var severity = severity || 'info';\n             var sticky = sticky || false;\n+            var maxNsNotifications = 5;\n             thNotify.notifications.push({\n                 message: message,\n                 severity: severity,\n                 sticky: sticky\n             });\n-            if(!sticky){\n+\n+            if (!sticky) {\n+                if (thNotify.notifications.length > maxNsNotifications) {\n+                    /* Replicate shift code to avoid pruning during rapid retriggers\n+                     * otheriwse we could use $timeout(thNotify.shift) here */\n+                    for(var i=0;i<thNotify.notifications.length; i++) {","path":"webapp/app/js/services/main.js","position":16,"original_position":16,"commit_id":"ab5a301b468903a1422d8ed785fe9fa2bb5336e4","original_commit_id":"ab5a301b468903a1422d8ed785fe9fa2bb5336e4","user":{"login":"camd","id":419924,"avatar_url":"https://avatars.githubusercontent.com/u/419924?v=3","gravatar_id":"","url":"https://api.github.com/users/camd","html_url":"https://github.com/camd","followers_url":"https://api.github.com/users/camd/followers","following_url":"https://api.github.com/users/camd/following{/other_user}","gists_url":"https://api.github.com/users/camd/gists{/gist_id}","starred_url":"https://api.github.com/users/camd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camd/subscriptions","organizations_url":"https://api.github.com/users/camd/orgs","repos_url":"https://api.github.com/users/camd/repos","events_url":"https://api.github.com/users/camd/events{/privacy}","received_events_url":"https://api.github.com/users/camd/received_events","type":"User","site_admin":false},"body":"I wonder if reusing the ``shift`` code didn't work because of that ``return`` there.  If you just call ``shift`` it will return from shift, but not from this code.  which would mean it would still call the ``$timeout`` on line 205.  Maybe that was the problem?","created_at":"2015-04-23T00:46:21Z","updated_at":"2015-04-23T00:46:21Z","html_url":"https://github.com/mozilla/treeherder-ui/pull/483#discussion_r28928538","pull_request_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483","_links":{"self":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments/28928538"},"html":{"href":"https://github.com/mozilla/treeherder-ui/pull/483#discussion_r28928538"},"pull_request":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483","id":33869233,"html_url":"https://github.com/mozilla/treeherder-ui/pull/483","diff_url":"https://github.com/mozilla/treeherder-ui/pull/483.diff","patch_url":"https://github.com/mozilla/treeherder-ui/pull/483.patch","issue_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/483","number":483,"state":"open","locked":false,"title":"Bug 1148664 - Expire non-sticky notifications with a max queue","user":{"login":"tojonmz","id":3660661,"avatar_url":"https://avatars.githubusercontent.com/u/3660661?v=3","gravatar_id":"","url":"https://api.github.com/users/tojonmz","html_url":"https://github.com/tojonmz","followers_url":"https://api.github.com/users/tojonmz/followers","following_url":"https://api.github.com/users/tojonmz/following{/other_user}","gists_url":"https://api.github.com/users/tojonmz/gists{/gist_id}","starred_url":"https://api.github.com/users/tojonmz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tojonmz/subscriptions","organizations_url":"https://api.github.com/users/tojonmz/orgs","repos_url":"https://api.github.com/users/tojonmz/repos","events_url":"https://api.github.com/users/tojonmz/events{/privacy}","received_events_url":"https://api.github.com/users/tojonmz/received_events","type":"User","site_admin":false},"body":"This work fixes Bugzilla bug [1148664](https://bugzilla.mozilla.org/show_bug.cgi?id=1148664).\r\n\r\nThis prevents the UX problem of sequential notifications from tiling down the page and blocking the jobs and job panel. Specifically we now:\r\n\r\n* enforce a maximum number of notifications (proposing 5)\r\n* relocate them to the left side over the revision table so we don't obscure jobs\r\n* expire/prune 'old' non-sticky notifications when new ones arrive\r\n* reduce the height of all notifications\r\n* align the 'X\" close icon for sticky notifications to the text baseline\r\n* use a new yellow 'warning' notification if the user retriggers before the job is loaded\r\n* inject the job type (eg. 'B', 'Cpp') into retrigger success messages since the notifications cascade\r\n* make the thModelErrors catch notification non-sticky\r\n* support sticky notifications (will appear at the 'top') with co-incident non-sticky ('below', cascading)\r\n\r\nThere's lots of behaviors to check and test, some of them:\r\n\r\n* retrigger without being logged in\r\n* retrigger without LDAP access (my situation here)\r\n* retrigger with full access (LDAP access)\r\n* issue rapid retriggers before the job loads (should produce our new yellow warning message)\r\n* issue other notifications (eg. Save Classification, PinAll, etc) in combination\r\n* issue persistent/sticky and then issue non-sticky notifications\r\n\r\nI've done a lot of testing, and everything seems fine so far. I wanted to use `$timeout(thNotify.shift)` directly in the for loop which prunes the non-sticky notifications, but during stress testing with many rapid notifications, it appears that `$timeout(thNotify.shift)` will start to do weird things, pruning the queue where the 4000ms timeout should not have occurred. So I chose to duplicate the `shift` code, which appears to work perfectly.\r\n\r\nSo here's what we used to have (imagine for the sake of my screen grab these were successes):\r\n\r\n![current](https://cloud.githubusercontent.com/assets/3660661/7277309/46e9a2f8-e8dd-11e4-8884-eb1d5d782d16.jpg)\r\n\r\nHere's is proposed (simulating a max of 5 retriggers I didn't want to actually do):\r\n\r\n![proposed](https://cloud.githubusercontent.com/assets/3660661/7277453/2b97308c-e8de-11e4-8559-a51eeb1469c3.jpg)\r\n\r\nHere is an example of a successful retrigger with job type identifier:\r\n\r\n![successfulretrigger](https://cloud.githubusercontent.com/assets/3660661/7284932/d08cff4c-e90e-11e4-9e7e-84cbae566792.jpg)\r\n\r\nHere is an edge case showing sequential retriggers before the job has loaded (it's typically sporadic and mixed in with successes):\r\n\r\n![notyetloadedproposed](https://cloud.githubusercontent.com/assets/3660661/7277479/4accf73e-e8de-11e4-90f4-a870966884c1.jpg)\r\n\r\nThere's all sorts of fun variations you can try in testing, but everything seems to be behaving as I expect, on both browsers. Sheriffs have signed off on all behaviors and re-location.\r\n\r\nTested on OSX 10.9.5:\r\nFF Release **37.0.2**\r\nChrome Latest Release **42.0.2311.90** (64-bit)\r\n\r\nAdding @camd for review and @maurodoglio for visibility.","created_at":"2015-04-22T15:22:40Z","updated_at":"2015-04-23T00:46:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bb1ac45a4dd677a26b3b350f8bdc2f0b2f78fa88","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483/commits","review_comments_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483/comments","review_comment_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/483/comments","statuses_url":"https://api.github.com/repos/mozilla/treeherder-ui/statuses/ab5a301b468903a1422d8ed785fe9fa2bb5336e4","head":{"label":"tojonmz:expire-notifications","ref":"expire-notifications","sha":"ab5a301b468903a1422d8ed785fe9fa2bb5336e4","user":{"login":"tojonmz","id":3660661,"avatar_url":"https://avatars.githubusercontent.com/u/3660661?v=3","gravatar_id":"","url":"https://api.github.com/users/tojonmz","html_url":"https://github.com/tojonmz","followers_url":"https://api.github.com/users/tojonmz/followers","following_url":"https://api.github.com/users/tojonmz/following{/other_user}","gists_url":"https://api.github.com/users/tojonmz/gists{/gist_id}","starred_url":"https://api.github.com/users/tojonmz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tojonmz/subscriptions","organizations_url":"https://api.github.com/users/tojonmz/orgs","repos_url":"https://api.github.com/users/tojonmz/repos","events_url":"https://api.github.com/users/tojonmz/events{/privacy}","received_events_url":"https://api.github.com/users/tojonmz/received_events","type":"User","site_admin":false},"repo":{"id":21174887,"name":"treeherder-ui","full_name":"tojonmz/treeherder-ui","owner":{"login":"tojonmz","id":3660661,"avatar_url":"https://avatars.githubusercontent.com/u/3660661?v=3","gravatar_id":"","url":"https://api.github.com/users/tojonmz","html_url":"https://github.com/tojonmz","followers_url":"https://api.github.com/users/tojonmz/followers","following_url":"https://api.github.com/users/tojonmz/following{/other_user}","gists_url":"https://api.github.com/users/tojonmz/gists{/gist_id}","starred_url":"https://api.github.com/users/tojonmz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tojonmz/subscriptions","organizations_url":"https://api.github.com/users/tojonmz/orgs","repos_url":"https://api.github.com/users/tojonmz/repos","events_url":"https://api.github.com/users/tojonmz/events{/privacy}","received_events_url":"https://api.github.com/users/tojonmz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tojonmz/treeherder-ui","description":"The UI for treeherder, a replacement for TBPL.","fork":true,"url":"https://api.github.com/repos/tojonmz/treeherder-ui","forks_url":"https://api.github.com/repos/tojonmz/treeherder-ui/forks","keys_url":"https://api.github.com/repos/tojonmz/treeherder-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tojonmz/treeherder-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tojonmz/treeherder-ui/teams","hooks_url":"https://api.github.com/repos/tojonmz/treeherder-ui/hooks","issue_events_url":"https://api.github.com/repos/tojonmz/treeherder-ui/issues/events{/number}","events_url":"https://api.github.com/repos/tojonmz/treeherder-ui/events","assignees_url":"https://api.github.com/repos/tojonmz/treeherder-ui/assignees{/user}","branches_url":"https://api.github.com/repos/tojonmz/treeherder-ui/branches{/branch}","tags_url":"https://api.github.com/repos/tojonmz/treeherder-ui/tags","blobs_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tojonmz/treeherder-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/tojonmz/treeherder-ui/languages","stargazers_url":"https://api.github.com/repos/tojonmz/treeherder-ui/stargazers","contributors_url":"https://api.github.com/repos/tojonmz/treeherder-ui/contributors","subscribers_url":"https://api.github.com/repos/tojonmz/treeherder-ui/subscribers","subscription_url":"https://api.github.com/repos/tojonmz/treeherder-ui/subscription","commits_url":"https://api.github.com/repos/tojonmz/treeherder-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/tojonmz/treeherder-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/tojonmz/treeherder-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/tojonmz/treeherder-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/tojonmz/treeherder-ui/contents/{+path}","compare_url":"https://api.github.com/repos/tojonmz/treeherder-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tojonmz/treeherder-ui/merges","archive_url":"https://api.github.com/repos/tojonmz/treeherder-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tojonmz/treeherder-ui/downloads","issues_url":"https://api.github.com/repos/tojonmz/treeherder-ui/issues{/number}","pulls_url":"https://api.github.com/repos/tojonmz/treeherder-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/tojonmz/treeherder-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/tojonmz/treeherder-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tojonmz/treeherder-ui/labels{/name}","releases_url":"https://api.github.com/repos/tojonmz/treeherder-ui/releases{/id}","created_at":"2014-06-24T17:50:28Z","updated_at":"2015-04-21T19:29:16Z","pushed_at":"2015-04-22T15:18:33Z","git_url":"git://github.com/tojonmz/treeherder-ui.git","ssh_url":"git@github.com:tojonmz/treeherder-ui.git","clone_url":"https://github.com/tojonmz/treeherder-ui.git","svn_url":"https://github.com/tojonmz/treeherder-ui","homepage":"https://wiki.mozilla.org/Auto-tools/Projects/Treeherder","size":14629,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"a417cc8bd6c210e3c398723370625414eab52f1b","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":10973059,"name":"treeherder-ui","full_name":"mozilla/treeherder-ui","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/treeherder-ui","description":"The UI for treeherder, a replacement for TBPL. See wiki page for where to file bugs.","fork":false,"url":"https://api.github.com/repos/mozilla/treeherder-ui","forks_url":"https://api.github.com/repos/mozilla/treeherder-ui/forks","keys_url":"https://api.github.com/repos/mozilla/treeherder-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/treeherder-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/treeherder-ui/teams","hooks_url":"https://api.github.com/repos/mozilla/treeherder-ui/hooks","issue_events_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/treeherder-ui/events","assignees_url":"https://api.github.com/repos/mozilla/treeherder-ui/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/treeherder-ui/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/treeherder-ui/tags","blobs_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/treeherder-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/treeherder-ui/languages","stargazers_url":"https://api.github.com/repos/mozilla/treeherder-ui/stargazers","contributors_url":"https://api.github.com/repos/mozilla/treeherder-ui/contributors","subscribers_url":"https://api.github.com/repos/mozilla/treeherder-ui/subscribers","subscription_url":"https://api.github.com/repos/mozilla/treeherder-ui/subscription","commits_url":"https://api.github.com/repos/mozilla/treeherder-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/treeherder-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/treeherder-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/treeherder-ui/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/treeherder-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/treeherder-ui/merges","archive_url":"https://api.github.com/repos/mozilla/treeherder-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/treeherder-ui/downloads","issues_url":"https://api.github.com/repos/mozilla/treeherder-ui/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/treeherder-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/treeherder-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/treeherder-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/treeherder-ui/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/treeherder-ui/releases{/id}","created_at":"2013-06-26T16:25:19Z","updated_at":"2015-04-21T22:46:54Z","pushed_at":"2015-04-23T00:02:48Z","git_url":"git://github.com/mozilla/treeherder-ui.git","ssh_url":"git@github.com:mozilla/treeherder-ui.git","clone_url":"https://github.com/mozilla/treeherder-ui.git","svn_url":"https://github.com/mozilla/treeherder-ui","homepage":"https://wiki.mozilla.org/Auto-tools/Projects/Treeherder","size":20669,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":6,"forks":43,"open_issues":6,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483"},"html":{"href":"https://github.com/mozilla/treeherder-ui/pull/483"},"issue":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/issues/483"},"comments":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/issues/483/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/pulls/483/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/treeherder-ui/statuses/ab5a301b468903a1422d8ed785fe9fa2bb5336e4"}}}}