@@ -318,10 +318,11 @@ async function sendInterviewCompletedNotifications () {
318
318
]
319
319
}
320
320
321
- const interviews = await Interview . findAll ( {
321
+ let interviews = await Interview . findAll ( {
322
322
where : filter ,
323
323
raw : true
324
324
} )
325
+ interviews = _ . map ( _ . values ( _ . groupBy ( interviews , 'jobCandidateId' ) ) , ( interviews ) => _ . maxBy ( interviews , 'round' ) )
325
326
326
327
const jobCandidates = await JobCandidate . findAll ( { where : { id : _ . map ( interviews , 'jobCandidateId' ) } } )
327
328
const jcMap = _ . keyBy ( jobCandidates , 'id' )
@@ -418,28 +419,27 @@ async function sendPostInterviewActionNotifications () {
418
419
const projectJcs = _ . filter ( completedJobCandidates , jc => jc . jobId === projectJob . id )
419
420
numCandidates += projectJcs . length
420
421
for ( const projectJc of projectJcs ) {
421
- for ( const interview of projectJc . interviews ) {
422
- const d = await getDataForInterview ( interview , projectJc , projectJob )
423
- if ( ! d ) { continue }
424
- d . jobUrl = `${ config . TAAS_APP_URL } /${ projectId } /positions/${ projectJob . id } `
425
- webNotifications . push ( {
426
- serviceId : 'web' ,
427
- type : template ,
428
- details : {
429
- recipients : projectTeamRecipients ,
430
- contents : {
431
- jobTitle : d . jobTitle ,
432
- teamName : project . name ,
433
- projectId,
434
- jobId : projectJob . id ,
435
- userHandle : d . handle
436
- } ,
437
- version : 1
438
- }
439
- } )
422
+ const interview = _ . maxBy ( projectJc . interviews , 'round' )
423
+ const d = await getDataForInterview ( interview , projectJc , projectJob )
424
+ if ( ! d ) { continue }
425
+ d . jobUrl = `${ config . TAAS_APP_URL } /${ projectId } /positions/${ projectJob . id } `
426
+ webNotifications . push ( {
427
+ serviceId : 'web' ,
428
+ type : template ,
429
+ details : {
430
+ recipients : projectTeamRecipients ,
431
+ contents : {
432
+ jobTitle : d . jobTitle ,
433
+ teamName : project . name ,
434
+ projectId,
435
+ jobId : projectJob . id ,
436
+ userHandle : d . handle
437
+ } ,
438
+ version : 1
439
+ }
440
+ } )
440
441
441
- teamInterviews . push ( d )
442
- }
442
+ teamInterviews . push ( d )
443
443
}
444
444
}
445
445
0 commit comments