{"action":"created","comment":{"url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments/56705334","id":56705334,"diff_hunk":"@@ -52,26 +53,27 @@ function recurOpenShifts(now) {\n                     params: newOpenShiftParams\n                 };\n                 batchPayload.push(newOpenShiftRequest);\n-\n-                openShiftIDs.forEach(function(shiftID) {\n-                    // Delete the invalid open shifts\n-                    var shiftDeleteRequest = {\n-                        method: \"delete\",\n-                        url: \"/2/shifts/\" + shiftID,\n-                        params: {}\n-                    };\n-                    batchPayload.push(shiftDeleteRequest);\n-                });\n-\n-                console.log('Adding ', correctNumberOfOpenShiftsToAdd, ' open shifts to the time: ', targetTime.toString(), '. Deleting incorrect count of open shifts--their shift IDs: ', openShiftIDs);\n-                WhenIWork.post('batch', batchPayload);\n             }\n+            // Batch delete the invalid open shifts in two cases: 1) correctNumberOfOpenShiftsToAdd > 0; we need to add open shifts\n+            // and 2) correctNumberOfOpenShiftsToAdd < 0; our open shift count is too high\n+            openShiftIDs.forEach(function(shiftID) {\n+                var shiftDeleteRequest = {\n+                    method: \"delete\",\n+                    url: \"/2/shifts/\" + shiftID,\n+                    params: {}\n+                };\n+                batchPayload.push(shiftDeleteRequest);\n+            });\n+\n+            if (correctNumberOfOpenShiftsToAdd < 0) { correctNumberOfOpenShiftsToAdd = 'no'; }\n+            console.log('Adding ', correctNumberOfOpenShiftsToAdd, ' open shifts to the time: ', targetTime.toString(), '. Deleting incorrect count of open shifts--their shift IDs: ', openShiftIDs);\n+            WhenIWork.post('batch', batchPayload);\n         })\n     }\n }\n \n // Checks if open shifts are already present a week from the targetTime\n-// Callback params: callback(openShiftsNeedToBeAddedBOOL, openShiftIDs, correctNumberOfOpenShiftsToAdd, targetTimeMomentObj);\n+// Callback params: callback(openShiftIDs, correctNumberOfOpenShiftsToAdd, targetTimeMomentObj);","path":"jobs/scheduling/RecurOpenShifts.js","position":61,"original_position":61,"commit_id":"193cbec3e5a0ca1814c378412b2bf3ba60a3ac39","original_commit_id":"193cbec3e5a0ca1814c378412b2bf3ba60a3ac39","user":{"login":"cjcodes","id":805867,"avatar_url":"https://avatars.githubusercontent.com/u/805867?v=3","gravatar_id":"","url":"https://api.github.com/users/cjcodes","html_url":"https://github.com/cjcodes","followers_url":"https://api.github.com/users/cjcodes/followers","following_url":"https://api.github.com/users/cjcodes/following{/other_user}","gists_url":"https://api.github.com/users/cjcodes/gists{/gist_id}","starred_url":"https://api.github.com/users/cjcodes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjcodes/subscriptions","organizations_url":"https://api.github.com/users/cjcodes/orgs","repos_url":"https://api.github.com/users/cjcodes/repos","events_url":"https://api.github.com/users/cjcodes/events{/privacy}","received_events_url":"https://api.github.com/users/cjcodes/received_events","type":"User","site_admin":false},"body":"Can we call the first param of the callback something different? extraOpenShiftsToDelete or something? Took me a while to understand what this was doing.","created_at":"2016-03-18T18:53:38Z","updated_at":"2016-03-18T18:53:38Z","html_url":"https://github.com/CrisisTextLine/Elmer/pull/48#discussion_r56705334","pull_request_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments/56705334"},"html":{"href":"https://github.com/CrisisTextLine/Elmer/pull/48#discussion_r56705334"},"pull_request":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48","id":63142436,"html_url":"https://github.com/CrisisTextLine/Elmer/pull/48","diff_url":"https://github.com/CrisisTextLine/Elmer/pull/48.diff","patch_url":"https://github.com/CrisisTextLine/Elmer/pull/48.patch","issue_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/48","number":48,"state":"open","locked":false,"title":"change open shifts to modify open shift count if there are too many open shifts","user":{"login":"tongxiang","id":5678066,"avatar_url":"https://avatars.githubusercontent.com/u/5678066?v=3","gravatar_id":"","url":"https://api.github.com/users/tongxiang","html_url":"https://github.com/tongxiang","followers_url":"https://api.github.com/users/tongxiang/followers","following_url":"https://api.github.com/users/tongxiang/following{/other_user}","gists_url":"https://api.github.com/users/tongxiang/gists{/gist_id}","starred_url":"https://api.github.com/users/tongxiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tongxiang/subscriptions","organizations_url":"https://api.github.com/users/tongxiang/orgs","repos_url":"https://api.github.com/users/tongxiang/repos","events_url":"https://api.github.com/users/tongxiang/events{/privacy}","received_events_url":"https://api.github.com/users/tongxiang/received_events","type":"User","site_admin":false},"body":"#### What's this PR do?\r\nPreviously, open shift recurrence only checked to see if the `correctNumberOfOpenShiftsToAdd` param was greater than zero. In that case, we'd add shifts. In other cases, we'd do nothing. \r\n\r\nThis PR changes that logic so that we check to see if the `correctNumberOfOpenShiftsToAdd` param is negative. (That means that the number of shifts open is greater than what we actually want.) \r\n\r\nIn that case, we delete shifts. \r\n\r\n#### how to test this?\r\nCreating open shift times that are 1) greater than the expected amount, 2) less than the expected amount, and 3) just right in the test WiW environment. Running it. ","created_at":"2016-03-16T21:55:24Z","updated_at":"2016-03-18T18:53:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"65d68b8c44b47b48743b04871dd054ac9c234c2b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48/commits","review_comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48/comments","review_comment_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/48/comments","statuses_url":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/193cbec3e5a0ca1814c378412b2bf3ba60a3ac39","head":{"label":"CrisisTextLine:open-shift-changes","ref":"open-shift-changes","sha":"193cbec3e5a0ca1814c378412b2bf3ba60a3ac39","user":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"repo":{"id":47287892,"name":"Elmer","full_name":"CrisisTextLine/Elmer","owner":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CrisisTextLine/Elmer","description":"","fork":false,"url":"https://api.github.com/repos/CrisisTextLine/Elmer","forks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/forks","keys_url":"https://api.github.com/repos/CrisisTextLine/Elmer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CrisisTextLine/Elmer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CrisisTextLine/Elmer/teams","hooks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/hooks","issue_events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/events{/number}","events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/events","assignees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/assignees{/user}","branches_url":"https://api.github.com/repos/CrisisTextLine/Elmer/branches{/branch}","tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/tags","blobs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/refs{/sha}","trees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/{sha}","languages_url":"https://api.github.com/repos/CrisisTextLine/Elmer/languages","stargazers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/stargazers","contributors_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contributors","subscribers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscribers","subscription_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscription","commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/commits{/sha}","git_commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/commits{/sha}","comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/comments{/number}","issue_comment_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/comments{/number}","contents_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contents/{+path}","compare_url":"https://api.github.com/repos/CrisisTextLine/Elmer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CrisisTextLine/Elmer/merges","archive_url":"https://api.github.com/repos/CrisisTextLine/Elmer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CrisisTextLine/Elmer/downloads","issues_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues{/number}","pulls_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls{/number}","milestones_url":"https://api.github.com/repos/CrisisTextLine/Elmer/milestones{/number}","notifications_url":"https://api.github.com/repos/CrisisTextLine/Elmer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CrisisTextLine/Elmer/labels{/name}","releases_url":"https://api.github.com/repos/CrisisTextLine/Elmer/releases{/id}","deployments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/deployments","created_at":"2015-12-02T20:51:51Z","updated_at":"2016-01-13T21:24:30Z","pushed_at":"2016-03-18T14:14:47Z","git_url":"git://github.com/CrisisTextLine/Elmer.git","ssh_url":"git@github.com:CrisisTextLine/Elmer.git","clone_url":"https://github.com/CrisisTextLine/Elmer.git","svn_url":"https://github.com/CrisisTextLine/Elmer","homepage":null,"size":138,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":1,"default_branch":"master"}},"base":{"label":"CrisisTextLine:master","ref":"master","sha":"7ff1357b7eb403fe18d067786ce35975caa31046","user":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"repo":{"id":47287892,"name":"Elmer","full_name":"CrisisTextLine/Elmer","owner":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CrisisTextLine/Elmer","description":"","fork":false,"url":"https://api.github.com/repos/CrisisTextLine/Elmer","forks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/forks","keys_url":"https://api.github.com/repos/CrisisTextLine/Elmer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CrisisTextLine/Elmer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CrisisTextLine/Elmer/teams","hooks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/hooks","issue_events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/events{/number}","events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/events","assignees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/assignees{/user}","branches_url":"https://api.github.com/repos/CrisisTextLine/Elmer/branches{/branch}","tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/tags","blobs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/refs{/sha}","trees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/{sha}","languages_url":"https://api.github.com/repos/CrisisTextLine/Elmer/languages","stargazers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/stargazers","contributors_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contributors","subscribers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscribers","subscription_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscription","commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/commits{/sha}","git_commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/commits{/sha}","comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/comments{/number}","issue_comment_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/comments{/number}","contents_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contents/{+path}","compare_url":"https://api.github.com/repos/CrisisTextLine/Elmer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CrisisTextLine/Elmer/merges","archive_url":"https://api.github.com/repos/CrisisTextLine/Elmer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CrisisTextLine/Elmer/downloads","issues_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues{/number}","pulls_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls{/number}","milestones_url":"https://api.github.com/repos/CrisisTextLine/Elmer/milestones{/number}","notifications_url":"https://api.github.com/repos/CrisisTextLine/Elmer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CrisisTextLine/Elmer/labels{/name}","releases_url":"https://api.github.com/repos/CrisisTextLine/Elmer/releases{/id}","deployments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/deployments","created_at":"2015-12-02T20:51:51Z","updated_at":"2016-01-13T21:24:30Z","pushed_at":"2016-03-18T14:14:47Z","git_url":"git://github.com/CrisisTextLine/Elmer.git","ssh_url":"git@github.com:CrisisTextLine/Elmer.git","clone_url":"https://github.com/CrisisTextLine/Elmer.git","svn_url":"https://github.com/CrisisTextLine/Elmer","homepage":null,"size":138,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48"},"html":{"href":"https://github.com/CrisisTextLine/Elmer/pull/48"},"issue":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/48"},"comments":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/193cbec3e5a0ca1814c378412b2bf3ba60a3ac39"}}}}