1
1
// @ts -check
2
2
3
+ // The number of days a project must be updated within
4
+ const DAYS_UPDATED_WITHIN = 14
5
+
3
6
const activeDevelopmentStatuses = [
4
7
'In Kickoff' ,
5
8
'In RFC' ,
@@ -23,6 +26,7 @@ const GET_PROJECT_CARDS = `
23
26
__typename
24
27
... on Issue {
25
28
id
29
+ createdAt
26
30
url
27
31
state
28
32
assignees(first: 10) {
@@ -61,10 +65,10 @@ module.exports = async ({ github, core }) => {
61
65
const isDryRun = process . env . DRY_RUN === 'true' ?? false
62
66
63
67
const currentDate = new Date ( )
64
- const fourteenDaysAgo = new Date (
65
- currentDate . getFullYear ( ) ,
66
- currentDate . getMonth ( ) ,
67
- currentDate . getDate ( ) - 14
68
+ // Create a date by subtracting DAYS_UPDATED_WITHIN days
69
+ // (converted to milliseconds) from the current date in milliseconds.
70
+ const requiredUpdatedByDate = new Date (
71
+ currentDate . getTime ( ) - DAYS_UPDATED_WITHIN * 24 * 60 * 60 * 1000
68
72
)
69
73
70
74
// Fetch project cards with their associated issue data
@@ -77,8 +81,13 @@ module.exports = async ({ github, core }) => {
77
81
78
82
for ( const node of result . repository . projectV2 . items . nodes ) {
79
83
const issue = node . content
80
- // If we're not looking at an open issue, move along
81
- if ( issue . __typename !== 'Issue' || issue . state !== 'OPEN' ) continue
84
+ // If we're not looking at an open issue older than the required update date, move along
85
+ if (
86
+ issue . __typename !== 'Issue' ||
87
+ issue . state !== 'OPEN' ||
88
+ new Date ( issue . createdAt ) > requiredUpdatedByDate
89
+ )
90
+ continue
82
91
83
92
// Check the status of the card to make sure the project is in active development
84
93
const status = node . fieldValueByName . name
@@ -89,7 +98,7 @@ module.exports = async ({ github, core }) => {
89
98
if (
90
99
// Check if the issue has been commented on in the last 14 days
91
100
! comments . some (
92
- ( comment ) => new Date ( comment . createdAt ) > fourteenDaysAgo
101
+ ( comment ) => new Date ( comment . createdAt ) > requiredUpdatedByDate
93
102
)
94
103
) {
95
104
// If not, leave a reminder comment on the issue
0 commit comments