Remove unnecessary complexity from KPI script (#27850)

This commit is contained in:
Luke Heath 2025-04-04 12:39:32 -05:00 committed by GitHub
parent 2d19865ab0
commit 264664d084
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
---------------------------------------