@@ -44,6 +44,13 @@ const completeAllCopilotRequests = async (req, projectId, _transaction, _member)
4444 const allCopilotRequests = await models . CopilotRequest . findAll ( {
4545 where : {
4646 projectId,
47+ status : {
48+ [ Op . in ] : [
49+ COPILOT_REQUEST_STATUS . APPROVED ,
50+ COPILOT_REQUEST_STATUS . NEW ,
51+ COPILOT_REQUEST_STATUS . SEEKING ,
52+ ] ,
53+ }
4754 } ,
4855 transaction : _transaction ,
4956 } ) ;
@@ -127,8 +134,9 @@ const completeAllCopilotRequests = async (req, projectId, _transaction, _member)
127134 req . log . debug ( `updated all copilot applications` ) ;
128135
129136 const memberDetails = await util . getMemberDetailsByUserIds ( [ _member . userId ] , req . log , req . id ) ;
137+ const member = memberDetails [ 0 ] ;
130138
131- req . log . debug ( `member details: ${ JSON . stringify ( memberDetails ) } ` ) ;
139+ req . log . debug ( `member details: ${ JSON . stringify ( member ) } ` ) ;
132140
133141 const emailEventType = CONNECT_NOTIFICATION_EVENT . EXTERNAL_ACTION_EMAIL ;
134142 const copilotPortalUrl = config . get ( 'copilotPortalUrl' ) ;
@@ -146,14 +154,14 @@ const completeAllCopilotRequests = async (req, projectId, _transaction, _member)
146154 opportunity_type : getCopilotTypeLabel ( requestData . projectType ) ,
147155 opportunity_title : requestData . opportunityTitle ,
148156 start_date : moment . utc ( requestData . startDate ) . format ( 'DD-MM-YYYY' ) ,
149- user_name : memberDetails ? memberDetails . handle : "" ,
157+ user_name : member ? member . handle : "" ,
150158 } ,
151159 sendgrid_template_id : TEMPLATE_IDS . COPILOT_ALREADY_PART_OF_PROJECT ,
152- recipients : [ memberDetails . email ] ,
160+ recipients : [ member . email ] ,
153161 version : 'v3' ,
154162 } , req . log ) ;
155163
156- req . log . debug ( `Sent email to ${ memberDetails . email } ` ) ;
164+ req . log . debug ( `Sent email to ${ member . email } ` ) ;
157165 } ) ;
158166
159167 await _transaction . commit ( ) ;
0 commit comments