mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
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:
parent
04169ec84b
commit
8466671cef
1 changed files with 7 additions and 4 deletions
11
website/scripts/get-bug-and-pr-report.js
vendored
11
website/scripts/get-bug-and-pr-report.js
vendored
|
|
@ -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);
|
||||
}
|
||||
}//∞
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue