Skip to content

Commit 5406f56

Browse files
authored
[ci] fix for docs_pr_nudge.yaml (#17635)
1 parent 9583eee commit 5406f56

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/workflows/docs_pr_nudge.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,28 @@ jobs:
116116
const [comments, reviewComments, reviews, commits] = await Promise.all([
117117
github.paginate(github.rest.issues.listComments, { owner, repo, issue_number: prNum, per_page: 100 }),
118118
github.paginate(github.rest.pulls.listReviewComments, { owner, repo, pull_number: prNum, per_page: 100 }),
119-
github.paginate(github.rest.pulls.listReviews, { owner, repo, pull_number: prNum, per_page: 100 }),
120-
github.paginate(github.rest.pulls.listCommits, { owner, repo, pull_number: prNum, per_page: 100 }),
119+
github.paginate(github.rest.pulls.listReviews, { owner, repo, pull_number: prNum, per_page: 100 }),
120+
github.paginate(github.rest.pulls.listCommits, { owner, repo, pull_number: prNum, per_page: 100 }),
121121
]);
122122

123123
const author = pr.user.login;
124124
const assignees = pr.assignees.map(a => a.login);
125125

126126
const extract = (arr, whoFn, dateKey) =>
127-
arr.map(i => ({ who: whoFn(i), when: new Date(i[dateKey]) }))
128-
.filter(x => x.when);
127+
arr
128+
.map(i => {
129+
const d = new Date(i[dateKey]);
130+
return { who: whoFn(i), when: d };
131+
})
132+
.filter(x => x.when && !isNaN(x.when.getTime()));
129133

130134
const allEvents = [
131135
...extract(comments, c => c.user.login, 'created_at'),
132136
...extract(reviewComments, c => c.user.login, 'created_at'),
133137
...extract(reviews, r => r.user.login, 'submitted_at'),
134138
...extract(commits, c => c.author?.login || c.commit?.author?.name, 'commit.author.date'),
135139
{ who: author, when: new Date(pr.created_at) }
136-
];
140+
].filter(e => e.when && !isNaN(e.when.getTime()));
137141

138142
const authorEvents = allEvents.filter(e => e.who === author).map(e => e.when);
139143
const reviewerEvents = allEvents.filter(e => assignees.includes(e.who)).map(e => e.when);
@@ -142,8 +146,9 @@ jobs:
142146
const lastReviewerActivity = reviewerEvents.length ? new Date(Math.max(...reviewerEvents)) : new Date(0);
143147

144148
// last nudge time
145-
const nudgeTimes = comments.filter(c => c.body.includes(BOT_MARKER))
146-
.map(c => new Date(c.created_at));
149+
const nudgeTimes = comments
150+
.map(c => new Date(c.created_at))
151+
.filter(d => !isNaN(d.getTime()) && comments.find(cc => cc.body.includes(BOT_MARKER)));
147152
const lastNudgeTime = nudgeTimes.length ? new Date(Math.max(...nudgeTimes)) : new Date(0);
148153

149154
// RULE 1: nudge reviewers

0 commit comments

Comments
 (0)