From 264664d08426543ab907fd8e522f6e0e4ef9ead5 Mon Sep 17 00:00:00 2001 From: Luke Heath Date: Fri, 4 Apr 2025 12:39:32 -0500 Subject: [PATCH] Remove unnecessary complexity from KPI script (#27850) --- website/scripts/get-bug-and-pr-report.js | 104 ++--------------------- 1 file changed, 8 insertions(+), 96 deletions(-) diff --git a/website/scripts/get-bug-and-pr-report.js b/website/scripts/get-bug-and-pr-report.js index 488639da71..ebeff7482f 100644 --- a/website/scripts/get-bug-and-pr-report.js +++ b/website/scripts/get-bug-and-pr-report.js @@ -29,10 +29,6 @@ module.exports = { const NUMBER_OF_RESULTS_REQUESTED = 100; let daysSinceBugsWereOpened = []; - let daysSinceUnreleasedBugsWereOpened = []; - let daysSinceReleasedBugsWereOpened = []; - let allBugsWithUnreleasedLabel = []; - let allBugsWithReleasedLabel = []; let allBugs32DaysOrOlder = []; let allBugsCreatedInPastWeek = []; let allBugsClosedInPastWeek = []; @@ -46,22 +42,6 @@ module.exports = { let allNonPublicOpenPrs = []; let nonPublicPrsClosedInThePastThreeWeeks = []; - - - // Endpoint operations - let allBugsCreatedInPastWeekEndpointOps = []; - let allBugsCreatedInPastWeekEndpointOpsUnreleased = []; - let allBugsCreatedInPastWeekEndpointOpsReleased = []; - let allBugsCreatedInPastWeekEndpointOpsCustomerImpacting = []; - - // Mobile Device Management - let allBugsCreatedInPastWeekMobileDeviceManagement = []; - - let allBugsCreatedInPastWeekMobileDeviceManagementUnreleased = []; - let allBugsCreatedInPastWeekMobileDeviceManagementReleased = []; - let allBugsCreatedInPastWeekMobileDeviceManagementCustomerImpacting = []; - - await sails.helpers.flow.simultaneously([ // ██████╗ ██████╗ ███████╗███╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗ @@ -115,44 +95,8 @@ module.exports = { if (issue.labels.some(label => label.name.indexOf('customer-') >= 0)) { allBugsReportedByCustomersInPastWeek.push(issue); } - // Get Endpoint Ops KPIs - if (issue.labels.some(label => label.name === '#g-endpoint-ops')) { - allBugsCreatedInPastWeekEndpointOps.push(issue); - if (issue.labels.some(label => label.name === '~unreleased bug')) { - allBugsCreatedInPastWeekEndpointOpsUnreleased.push(issue); - } - else if (issue.labels.some(label => label.name === '~released bug')) { - allBugsCreatedInPastWeekEndpointOpsReleased.push(issue); - } - if (issue.labels.some(label => label.name.indexOf('customer-') >= 0)) { - allBugsCreatedInPastWeekEndpointOpsCustomerImpacting.push(issue); - } - } - // Get MDM KPIs - if (issue.labels.some(label => label.name === '#g-mdm')) { - allBugsCreatedInPastWeekMobileDeviceManagement.push(issue); - if (issue.labels.some(label => label.name === '~unreleased bug')) { - allBugsCreatedInPastWeekMobileDeviceManagementUnreleased.push(issue); - } - else if (issue.labels.some(label => label.name === '~released bug')) { - allBugsCreatedInPastWeekMobileDeviceManagementReleased.push(issue); - } - if (issue.labels.some(label => label.name.indexOf('customer-') >= 0)) { - allBugsCreatedInPastWeekMobileDeviceManagementCustomerImpacting.push(issue); - } - } } - daysSinceBugsWereOpened.push(timeOpenInDays); - // Send to released or unreleased bugs array - if (issue.labels.some(label => label.name === '~unreleased bug')) { - allBugsWithUnreleasedLabel.push(issue); - daysSinceUnreleasedBugsWereOpened.push(timeOpenInDays); - } else if (issue.labels.some(label => label.name === '~released bug')) { - allBugsWithReleasedLabel.push(issue); - daysSinceReleasedBugsWereOpened.push(timeOpenInDays); - } - } }, @@ -298,7 +242,7 @@ module.exports = { return pullRequests.length !== NUMBER_OF_RESULTS_REQUESTED; }, 10000); - for(let pullRequest of allPublicOpenPrs) { + for (let pullRequest of allPublicOpenPrs) { // Create a date object from the PR's created_at timestamp. let pullRequestOpenedOn = new Date(pullRequest.created_at); // Get the amount of time this issue has been open in milliseconds. @@ -359,9 +303,6 @@ module.exports = { // Get the averages from the arrays of results. let averageNumberOfDaysBugsAreOpenFor = Math.round(_.sum(daysSinceBugsWereOpened) / daysSinceBugsWereOpened.length); - let averageNumberOfDaysUnreleasedBugsAreOpenFor = Math.round(_.sum(daysSinceUnreleasedBugsWereOpened) / daysSinceUnreleasedBugsWereOpened.length); - let averageNumberOfDaysReleasedBugsAreOpenFor = Math.round(_.sum(daysSinceReleasedBugsWereOpened)/daysSinceReleasedBugsWereOpened.length); - let averageDaysPullRequestsAreOpenFor = Math.round(_.sum(daysSincePullRequestsWereOpened)/daysSincePullRequestsWereOpened.length); let averageDaysContributorPullRequestsAreOpenFor = Math.round(_.sum(daysSinceContributorPullRequestsWereOpened)/daysSinceContributorPullRequestsWereOpened.length); @@ -392,9 +333,8 @@ module.exports = { kpiResults.push( averageDaysContributorPullRequestsAreOpenFor, allBugs32DaysOrOlder.length, + averageNumberOfDaysBugsAreOpenFor, allBugsReportedByCustomersInPastWeek.length, - averageNumberOfDaysReleasedBugsAreOpenFor, - averageNumberOfDaysUnreleasedBugsAreOpenFor, allBugsCreatedInPastWeek.length, allBugsClosedInPastWeek.length,); @@ -409,51 +349,23 @@ module.exports = { Pull requests: --------------------------- - Average open time (no bots, no handbook, no ceo): ${averageDaysContributorPullRequestsAreOpenFor} days. + Average open time: ${averageDaysContributorPullRequestsAreOpenFor} days. - Number of open pull requests in the fleetdm/fleet Github repo (no bots, no handbook, no ceo): ${daysSinceContributorPullRequestsWereOpened.length} - - Average open time (all PRs): ${averageDaysPullRequestsAreOpenFor} days. - - Number of open pull requests in the fleetdm/fleet Github repo: ${daysSincePullRequestsWereOpened.length} + Number of open pull requests in the fleetdm/fleet Github repo: ${daysSinceContributorPullRequestsWereOpened.length} Bugs: --------------------------- - Average open time (released bugs): ${averageNumberOfDaysReleasedBugsAreOpenFor} days. - - Average open time (unreleased bugs): ${averageNumberOfDaysUnreleasedBugsAreOpenFor} days. - - Number of issues with the "bug" label closed in the past week: ${allBugsClosedInPastWeek.length} - Average open time (all bugs): ${averageNumberOfDaysBugsAreOpenFor} days. - Number of issues with the "bug" label opened in the past week: ${allBugsCreatedInPastWeek.length} - Number of open issues with the "bug" label in fleetdm/fleet: ${daysSinceBugsWereOpened.length} - Number of open issues with the "~released bug" label in fleetdm/fleet: ${allBugsWithReleasedLabel.length} + Bugs older than 32 days: ${allBugs32DaysOrOlder.length} - Number of open issues with the "~unreleased bug" label in fleetdm/fleet: ${allBugsWithUnreleasedLabel.length} + Bugs reported by customers in the past week: ${allBugsReportedByCustomersInPastWeek.length} - Endpoint Operations: - --------------------------- - Number of issues with the "#g-endpoint-ops" and "bug" labels opened in the past week: ${allBugsCreatedInPastWeekEndpointOps.length} + Number of issues with the "bug" label closed in the past week: ${allBugsClosedInPastWeek.length} - Number of issues with the "#g-endpoint-ops", "bug", and "customer-" labels opened in the past week: ${allBugsCreatedInPastWeekEndpointOpsCustomerImpacting.length} - - Number of issues with the "#g-endpoint-ops", "bug", and "~released bug" labels opened in the past week: ${allBugsCreatedInPastWeekEndpointOpsReleased.length} - - Number of issues with the "#g-endpoint-ops", "bug", and "~unreleased bug" labels opened in the past week: ${allBugsCreatedInPastWeekEndpointOpsUnreleased.length} - - MDM: - --------------------------- - Number of issues with the "#g-mdm" and "bug" labels opened in the past week: ${allBugsCreatedInPastWeekMobileDeviceManagement.length} - - Number of issues with the "#g-mdm", "bug", and "customer-" labels opened in the past week: ${allBugsCreatedInPastWeekMobileDeviceManagementCustomerImpacting.length} - - Number of issues with the "#g-mdm", "bug", and "~released bug" labels opened in the past week: ${allBugsCreatedInPastWeekMobileDeviceManagementReleased.length} - - Number of issues with the "#g-mdm", "bug", and "~unreleased bug" labels opened in the past week: ${allBugsCreatedInPastWeekMobileDeviceManagementUnreleased.length} + Number of issues with the "bug" label opened in the past week: ${allBugsCreatedInPastWeek.length} Handbook Pull requests ---------------------------------------