Exclude draft PRs from KPIs (#10327)

@eashaw DEF check this code, please. I didn't test it at all and wrote
it during a meeting and lots of interruptions.
This commit is contained in:
Mike McNeil 2023-03-06 15:57:53 -06:00 committed by GitHub
parent 04169ec84b
commit 8466671cef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,9 +111,9 @@ module.exports = {
baseHeaders
).retry();
// Filter the PRs we received from Github using the pull request's merged_at date.
// Exclude draft PRs and filter the PRs we received from Github using the pull request's merged_at date.
let resultsToAdd = closedPullRequests.filter((pullRequest)=>{
return threeWeeksAgo <= new Date(pullRequest.merged_at);
return !pullRequest.draft && threeWeeksAgo <= new Date(pullRequest.merged_at);
});
// Add the filtered array of PRs to the array of all pull requests merged in the past three weeks.
@ -168,6 +168,7 @@ module.exports = {
// If we received less results than we requested, we've reached the last page of the results.
return pullRequests.length !== NUMBER_OF_RESULTS_REQUESTED;
}, 10000);
for(let pullRequest of allOpenPullRequests) {
// Create a date object from the PR's created_at timestamp.
let pullRequestOpenedOn = new Date(pullRequest.created_at);
@ -175,8 +176,10 @@ module.exports = {
let timeOpenInMS = Math.abs(todaysDate - pullRequestOpenedOn);
// Convert the miliseconds to days and add the value to the daysSincePullRequestsWereOpened array
let timeOpenInDays = timeOpenInMS / ONE_DAY_IN_MILLISECONDS;
daysSincePullRequestsWereOpened.push(timeOpenInDays);
}
if (!pullRequest.draft) {// Exclude draft PRs
daysSincePullRequestsWereOpened.push(timeOpenInDays);
}
}//∞
}