From 320d4effad48b66bc725d5ce29ce81433af7854f Mon Sep 17 00:00:00 2001 From: Asher Engelberg Date: Thu, 14 Jul 2022 14:48:39 -0700 Subject: [PATCH 01/12] changed the log statement to make error statements more descriptive --- github-actions/add-update-label-weekly/add-label.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index c872aa61e6..1c0d4b2ff3 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -211,7 +211,7 @@ async function removeLabels(issueNum, ...labels) { }); console.log(`Removed "${label}" from issue #${issueNum}`); } catch (err) { - console.error(`No "${label}" label to remove for issue #${issueNum}`); + console.error(`Function failed to remove label ${label} for issue #${issueNum}. Please refer to the error below: /n ${err}`); } } } @@ -231,8 +231,8 @@ async function addLabels(issueNum, ...labels) { }); console.log(`Added these labels to issue #${issueNum}: ${labels}`); // If an error is found, the rest of the script does not stop. - } catch { - console.error(`Could not add these labels for issue #${issueNum}: ${labels}`); + } catch (err){ + console.error(`Function failed to add label ${labels} for issue #${issueNum}. Please refer to the error below: \n ${err}`); } } async function postComment(issueNum, assignees) { @@ -246,7 +246,7 @@ async function postComment(issueNum, assignees) { body: instructions, }); } catch (err) { - console.error(`Could not post a comment for issue #${issueNum}`); + console.error(`Function failed to post comment for issue#${issueNum}. Please refer to the error below: \n ${err}`); } } /*********************** @@ -280,7 +280,7 @@ async function getAssignees(issueNum) { assigneesLogins = filterForAssigneesLogins(assigneesData); return assigneesLogins } catch (err) { - console.error(`Failed request to get assignee from issue: #${issueNum}`) + console.error(`Function failed to return assignees for issue #${issueNum}. Please refer to the error below: \n${err}`) return null } } From 30017a6102fda1e22c07d44e5bf72de48fcc730a Mon Sep 17 00:00:00 2001 From: ssanger Date: Thu, 11 Aug 2022 15:53:22 -0700 Subject: [PATCH 02/12] made workflow on demand --- .github/workflows/add-update-label-weekly.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-update-label-weekly.yml b/.github/workflows/add-update-label-weekly.yml index 1162e203ef..96cddb0001 100644 --- a/.github/workflows/add-update-label-weekly.yml +++ b/.github/workflows/add-update-label-weekly.yml @@ -1,8 +1,9 @@ name: Add Update Label to Issues Weekly on: - schedule: - - cron: '0 7 * * 5' + workflow_dispatch +# schedule: +# - cron: '0 7 * * 5' jobs: Add-Update-Label-to-Issues-Weekly: From 24da5cf8c6bc9af5dec44d546ab51fede6a59943 Mon Sep 17 00:00:00 2001 From: ssanger Date: Thu, 11 Aug 2022 17:17:19 -0700 Subject: [PATCH 03/12] update --- github-actions/add-update-label-weekly/add-label.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index 1c0d4b2ff3..5870964346 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -7,9 +7,9 @@ var context; const statusUpdatedLabel = 'Status: Updated'; const toUpdateLabel = 'To Update !'; const inactiveLabel = '2 weeks inactive'; -const updatedByDays = 3; // number of days ago to check for to update label -const inactiveUpdatedByDays = 14; // number of days ago to check for inactive label -const commentByDays = 7; // number of days ago to check for comment by assignee +const updatedByDays = 1; // number of days ago to check for to update label +const inactiveUpdatedByDays = 1; // number of days ago to check for inactive label +const commentByDays = 1; // number of days ago to check for comment by assignee const threeDayCutoffTime = new Date() threeDayCutoffTime.setDate(threeDayCutoffTime.getDate() - updatedByDays) const sevenDayCutoffTime = new Date() From 238797a1adff5dc866a14c88b1cb7d0921355b95 Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 16:45:21 -0700 Subject: [PATCH 04/12] changed line 148 to False --- github-actions/add-update-label-weekly/add-label.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index 5870964346..020e7f5465 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -145,7 +145,7 @@ async function isTimelineOutdated(timeline, issueNum, assignees) { return {result: false, labels: statusUpdatedLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format - return {result: true, labels: inactiveLabel} + return {result: false} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < threeDayCutoffTime.valueOf())) { // returns true if issue was created before 3 days return {result: true, labels: toUpdateLabel} From fd753a1805814308688e6a14206b41f1d79ad802 Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 16:49:06 -0700 Subject: [PATCH 05/12] changed 148, 151, 154 to false --- github-actions/add-update-label-weekly/add-label.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index 020e7f5465..d6ee4a1469 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -145,13 +145,13 @@ async function isTimelineOutdated(timeline, issueNum, assignees) { return {result: false, labels: statusUpdatedLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format - return {result: false} + return {result: false, labels: inactiveLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < threeDayCutoffTime.valueOf())) { // returns true if issue was created before 3 days - return {result: true, labels: toUpdateLabel} + return {result: false, labels: toUpdateLabel} } else if (index === timeline.length-1) { // returns true if above two else ifs are false meaning issue was created within last 3 days - return {result: true, labels: statusUpdatedLabel} + return {result: false, labels: statusUpdatedLabel} } } else if (isMomentRecent(moment.created_at, sevenDayCutoffTime)) { // all the events of an issue between three and seven days will return true From 9f3166e45e457183652188f2f9beaca2b4b756e4 Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 16:52:33 -0700 Subject: [PATCH 06/12] deleted 140-143 --- github-actions/add-update-label-weekly/add-label.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index d6ee4a1469..adff0fafc3 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -137,11 +137,7 @@ async function getTimeline(issueNum) { async function isTimelineOutdated(timeline, issueNum, assignees) { for await (let [index, moment] of timeline.entries()) { - if (isMomentRecent(moment.created_at, threeDayCutoffTime)) { // all the events of an issue within last three days will return true - if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced within last three days - return {result: false, labels: statusUpdatedLabel} - } - else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days + if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days return {result: false, labels: statusUpdatedLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format From 9bf4bc53b225ff2381461307784ff04b4a869cf6 Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 17:04:37 -0700 Subject: [PATCH 07/12] deleted 153-155 --- github-actions/add-update-label-weekly/add-label.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index adff0fafc3..d3bc1a61f7 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -137,7 +137,11 @@ async function getTimeline(issueNum) { async function isTimelineOutdated(timeline, issueNum, assignees) { for await (let [index, moment] of timeline.entries()) { - if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days + if (isMomentRecent(moment.created_at, threeDayCutoffTime)) { // all the events of an issue within last three days will return true + if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced within last three days + return {result: false, labels: statusUpdatedLabel} + } + else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days return {result: false, labels: statusUpdatedLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format @@ -146,9 +150,6 @@ async function isTimelineOutdated(timeline, issueNum, assignees) { else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < threeDayCutoffTime.valueOf())) { // returns true if issue was created before 3 days return {result: false, labels: toUpdateLabel} } - else if (index === timeline.length-1) { // returns true if above two else ifs are false meaning issue was created within last 3 days - return {result: false, labels: statusUpdatedLabel} - } } else if (isMomentRecent(moment.created_at, sevenDayCutoffTime)) { // all the events of an issue between three and seven days will return true if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced between 3 and 7 days From 0279aca62ca157b97549480ffed476908b81e6da Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 17:09:43 -0700 Subject: [PATCH 08/12] 154 - 167 changed true to false --- github-actions/add-update-label-weekly/add-label.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index d3bc1a61f7..673a49d2d2 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -154,17 +154,17 @@ async function isTimelineOutdated(timeline, issueNum, assignees) { else if (isMomentRecent(moment.created_at, sevenDayCutoffTime)) { // all the events of an issue between three and seven days will return true if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced between 3 and 7 days console.log('between 3 and 7 cross referenced'); - return {result: false, labels: statusUpdatedLabel} + return {result: true, labels: statusUpdatedLabel} } else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented between 3 and 7 days console.log('between 3 and 7 commented'); - return {result: false, labels: statusUpdatedLabel} + return {result: true, labels: statusUpdatedLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format - return {result: true, labels: inactiveLabel} + return {result: false, labels: inactiveLabel} } else if (index === timeline.length-1) { // returns true if the latest event created is between 3 and 7 days - return {result: true, labels: toUpdateLabel} + return {result: false, labels: toUpdateLabel} } } else if (isMomentRecent(moment.created_at, fourteenDayCutoffTime)) { // all the events of an issue between seven and fourteen days will return true From 00444c2d5eb6ef86c602f8089fc60069fbf973ae Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 17:28:16 -0700 Subject: [PATCH 09/12] added tomato tomato to line 226 --- github-actions/add-update-label-weekly/add-label.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index 673a49d2d2..bac4782bee 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -223,7 +223,7 @@ async function addLabels(issueNum, ...labels) { await github.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: issueNum, + issue_number: issueNum, tomato tomato tomato labels: labels, }); console.log(`Added these labels to issue #${issueNum}: ${labels}`); From 8197ed2ab1f0a7dfeed5f5c45ff14c0ab99ef4ad Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 17:31:37 -0700 Subject: [PATCH 10/12] added let to line 221 --- github-actions/add-update-label-weekly/add-label.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index bac4782bee..97875b0378 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -218,12 +218,12 @@ async function removeLabels(issueNum, ...labels) { * @param {Array} labels an array containing the labels to add (captures the rest of the parameters) */ async function addLabels(issueNum, ...labels) { - try { + try { let // https://octokit.github.io/rest.js/v18#issues-add-labels await github.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: issueNum, tomato tomato tomato + issue_number: issueNum, labels: labels, }); console.log(`Added these labels to issue #${issueNum}: ${labels}`); From 5fc39b51548024dc540d71df60d74112d9dcabc3 Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 17:51:06 -0700 Subject: [PATCH 11/12] changed yaml workflow and deleted 140-143 in .js --- .github/workflows/add-update-label-weekly.yml | 5 +++-- github-actions/add-update-label-weekly/add-label.js | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/add-update-label-weekly.yml b/.github/workflows/add-update-label-weekly.yml index 1162e203ef..96cddb0001 100644 --- a/.github/workflows/add-update-label-weekly.yml +++ b/.github/workflows/add-update-label-weekly.yml @@ -1,8 +1,9 @@ name: Add Update Label to Issues Weekly on: - schedule: - - cron: '0 7 * * 5' + workflow_dispatch +# schedule: +# - cron: '0 7 * * 5' jobs: Add-Update-Label-to-Issues-Weekly: diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index c872aa61e6..57e2e27913 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -137,11 +137,7 @@ async function getTimeline(issueNum) { async function isTimelineOutdated(timeline, issueNum, assignees) { for await (let [index, moment] of timeline.entries()) { - if (isMomentRecent(moment.created_at, threeDayCutoffTime)) { // all the events of an issue within last three days will return true - if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced within last three days - return {result: false, labels: statusUpdatedLabel} - } - else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days + if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days return {result: false, labels: statusUpdatedLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format From ae687033f4cb1f2b3bfcc45e62d35fe1b889c572 Mon Sep 17 00:00:00 2001 From: ssanger Date: Sat, 13 Aug 2022 17:53:24 -0700 Subject: [PATCH 12/12] added let to line 224 --- github-actions/add-update-label-weekly/add-label.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/github-actions/add-update-label-weekly/add-label.js b/github-actions/add-update-label-weekly/add-label.js index 57e2e27913..afaeb6c720 100644 --- a/github-actions/add-update-label-weekly/add-label.js +++ b/github-actions/add-update-label-weekly/add-label.js @@ -137,7 +137,11 @@ async function getTimeline(issueNum) { async function isTimelineOutdated(timeline, issueNum, assignees) { for await (let [index, moment] of timeline.entries()) { - if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days + if (isMomentRecent(moment.created_at, threeDayCutoffTime)) { // all the events of an issue within last three days will return true + if (moment.event == 'cross-referenced' && isLinkedIssue(moment, issueNum)) { // checks if cross referenced within last three days + return {result: false, labels: statusUpdatedLabel} + } + else if (moment.event == 'commented' && isCommentByAssignees(moment, assignees)) { // checks if commented within last three days return {result: false, labels: statusUpdatedLabel} } else if (index === timeline.length-1 && (Date.parse(timeline[0].created_at) < fourteenDayCutoffTime.valueOf())) { // returns true if issue was created before 14 days after comparing the two dates in millisecond format @@ -217,7 +221,7 @@ async function removeLabels(issueNum, ...labels) { * @param {Array} labels an array containing the labels to add (captures the rest of the parameters) */ async function addLabels(issueNum, ...labels) { - try { + try { let // https://octokit.github.io/rest.js/v18#issues-add-labels await github.issues.addLabels({ owner: context.repo.owner,