@@ -20,22 +20,23 @@ const TASK_TYPE = 'opportunity-status-processor';
2020 * @returns {string } The opportunity title
2121 */
2222function getOpportunityTitle ( opportunityType ) {
23- switch ( opportunityType ) {
24- case 'cwv' :
25- return 'Core Web Vitals' ;
26- case 'meta-tags' :
27- return 'SEO Meta Tags' ;
28- case 'broken-back-links' :
29- return 'Broken Back Links' ;
30- case 'broken-links' :
31- return 'Broken Links' ;
32- default :
33- // Convert kebab-case to Title Case (e.g., "first-second" -> "First Second")
34- return opportunityType
35- . split ( '-' )
36- . map ( ( word ) => word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) )
37- . join ( ' ' ) ;
23+ const opportunityTitles = {
24+ cwv : 'Core Web Vitals' ,
25+ 'meta-tags' : 'SEO Meta Tags' ,
26+ 'broken-back-links' : 'Broken Back Links' ,
27+ 'broken-links' : 'Broken Links' ,
28+ } ;
29+
30+ // Check if the opportunity type exists in our map
31+ if ( opportunityTitles [ opportunityType ] ) {
32+ return opportunityTitles [ opportunityType ] ;
3833 }
34+
35+ // Convert kebab-case to Title Case (e.g., "first-second" -> "First Second")
36+ return opportunityType
37+ . split ( '-' )
38+ . map ( ( word ) => word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) )
39+ . join ( ' ' ) ;
3940}
4041
4142/**
@@ -75,11 +76,10 @@ export async function runOpportunityStatusProcessor(message, context) {
7576 // Process each opportunity
7677 for ( const opportunity of opportunities ) {
7778 const opportunityType = opportunity . getType ( ) ;
78- const opportunityId = opportunity . getId ( ) ;
7979
8080 // Get suggestions for this opportunity
8181 // eslint-disable-next-line no-await-in-loop
82- const suggestions = await site . getSuggestions ( opportunityId ) ;
82+ const suggestions = await opportunity . getSuggestions ( ) ;
8383
8484 // Get the opportunity title
8585 const opportunityTitle = getOpportunityTitle ( opportunityType ) ;
0 commit comments