From 614ee48e33f211d9d2e808a9faba193083eb0858 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Wed, 18 Dec 2024 19:31:09 +0100 Subject: [PATCH] Priority indicators: update logic to match new priority matrix We now ask different questions in our issue templates: https://github.com/Automattic/jetpack/pull/40501 This commit updates the logic to match the new questions and answers. It also captures the optional extra information ("other impact(s)") an issue can have, since that info can bump the severity, and in turn the priority, of an issue. See pfVjQF-su-p2 --- .../update-repo-gardening-priority-indicators | 4 ++ .../src/utils/parse-content/find-priority.js | 71 +++++++++++++++---- 2 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 projects/github-actions/repo-gardening/changelog/update-repo-gardening-priority-indicators diff --git a/projects/github-actions/repo-gardening/changelog/update-repo-gardening-priority-indicators b/projects/github-actions/repo-gardening/changelog/update-repo-gardening-priority-indicators new file mode 100644 index 0000000000000..bdaf44b56c165 --- /dev/null +++ b/projects/github-actions/repo-gardening/changelog/update-repo-gardening-priority-indicators @@ -0,0 +1,4 @@ +Significance: major +Type: changed + +Issue triage: update priority matrix. diff --git a/projects/github-actions/repo-gardening/src/utils/parse-content/find-priority.js b/projects/github-actions/repo-gardening/src/utils/parse-content/find-priority.js index 137effa04b940..35ccc8877bbcc 100644 --- a/projects/github-actions/repo-gardening/src/utils/parse-content/find-priority.js +++ b/projects/github-actions/repo-gardening/src/utils/parse-content/find-priority.js @@ -2,37 +2,78 @@ const debug = require( '../debug' ); /** * Figure out the priority of the issue, based off issue contents. - * Logic follows this priority matrix: pciE2j-oG-p2 + * Logic follows this priority matrix: pfVjQF-su-p2 * * @param {string} body - The issue content. * @return {string} Priority of issue. */ function findPriority( body ) { + let priority = 'TBD'; + + debug( `find-priority: Looking for priority indicators in issue body: ${ body }` ); + // Look for priority indicators in body. const priorityRegex = - /###\sImpact\n\n(?.*)\n\n###\sAvailable\sworkarounds\?\n\n(?.*)\n/gm; + /###\sSite\sowner\simpact\n\n(?.*)\n\n###\sSeverity\n\n(?.*)\n\n###\sWhat\sother\simpact\(s\)\sdoes\sthis\sissue\shave\?\n\n(?.*)\n/gm; let match; while ( ( match = priorityRegex.exec( body ) ) ) { - const [ , impact = '', blocking = '' ] = match; + const { impact = '', extra = '' } = match.groups || {}; + let { severity = '' } = match.groups || {}; debug( - `find-priority: Reported priority indicators for issue: "${ impact }" / "${ blocking }"` + `find-priority: Reported priority indicators for issue: "${ impact }" / "${ severity }" / "${ extra }"` ); - if ( blocking === 'No and the platform is unusable' ) { - return impact === 'One' ? 'High' : 'BLOCKER'; - } else if ( blocking === 'No but the platform is still usable' ) { - return 'High'; - } else if ( blocking === 'Yes, difficult to implement' ) { - return impact === 'All' ? 'High' : 'Normal'; - } else if ( blocking !== '' && blocking !== '_No response_' ) { - return impact === 'All' || impact === 'Most (> 50%)' ? 'Normal' : 'Low'; + // Folks can provide additional information that can bump severity. + // We also do not want that extra information to downgrade the severity. + if ( extra !== '' && extra !== '_No response_' && extra !== 'No revenue impact' ) { + if ( + ( extra === 'Individual site owner revenue' || extra === 'Agency or developer revenue' ) && + severity !== 'Critical' + ) { + severity = 'Major'; + } else if ( extra === 'Platform revenue' ) { + severity = 'Critical'; + } + } + + const impactIndicators = { + isolated: 'Less than 20% of all', + scattered: 'Between 20% and 60% of all', + widespread: 'More than 60% of all', + }; + + if ( severity === 'Critical' ) { + priority = impact === impactIndicators.isolated ? 'High' : 'BLOCKER'; + } else if ( severity === 'Major' ) { + if ( impact === impactIndicators.widespread ) { + priority = 'BLOCKER'; + } else if ( impact === impactIndicators.scattered ) { + priority = 'High'; + } else { + priority = 'Normal'; + } + } else if ( severity === 'Moderate' ) { + if ( impact === impactIndicators.widespread ) { + priority = 'High'; + } else if ( impact === impactIndicators.scattered ) { + priority = 'Normal'; + } else { + priority = 'Low'; + } + } else if ( severity !== '' && severity !== '_No response_' ) { + priority = impact === impactIndicators.widespread ? 'Normal' : 'Low'; + } else { + priority = 'TBD'; } - return 'TBD'; } - debug( `find-priority: No priority indicators found.` ); - return 'TBD'; + debug( + `find-priority: ${ + priority === 'TBD' ? 'No ' : ' ' + }priority indicators found. Priority set to ${ priority }.` + ); + return priority; } module.exports = findPriority;