@@ -7,10 +7,9 @@ const models = require('../models')
7
7
const logger = require ( '../common/logger' )
8
8
const helper = require ( '../common/helper' )
9
9
const JobCandidateService = require ( '../services/JobCandidateService' )
10
- const ResourceBookingService = require ( '../services/ResourceBookingService' )
11
10
12
11
/**
13
- * Cancel all related resource bookings and all related candidates when a job is cancelled.
12
+ * Cancel all related related candidates when a job is cancelled.
14
13
*
15
14
* @param {Object } payload the event payload
16
15
* @returns {undefined }
@@ -33,7 +32,7 @@ async function cancelJob (payload) {
33
32
return
34
33
}
35
34
// pull data from db instead of directly extract data from the payload
36
- // since the payload may not contain all fields when it is from partically update operation.
35
+ // since the payload may not contain all fields when it is from partially update operation.
37
36
const job = await models . Job . findById ( payload . value . id )
38
37
const candidates = await models . JobCandidate . findAll ( {
39
38
where : {
@@ -44,39 +43,17 @@ async function cancelJob (payload) {
44
43
deletedAt : null
45
44
}
46
45
} )
47
- const resourceBookings = await models . ResourceBooking . findAll ( {
48
- where : {
49
- jobId : job . id ,
50
- status : {
51
- [ Op . not ] : 'cancelled'
52
- } ,
53
- deletedAt : null
54
- }
55
- } )
56
- await Promise . all ( [
57
- ...candidates . map ( candidate => JobCandidateService . partiallyUpdateJobCandidate (
58
- helper . getAuditM2Muser ( ) ,
59
- candidate . id ,
60
- { status : 'cancelled' }
61
- ) . then ( result => {
62
- logger . info ( {
63
- component : 'JobEventHandler' ,
64
- context : 'cancelJob' ,
65
- message : `id: ${ result . id } candidate got cancelled.`
66
- } )
67
- } ) ) ,
68
- ...resourceBookings . map ( resource => ResourceBookingService . partiallyUpdateResourceBooking (
69
- helper . getAuditM2Muser ( ) ,
70
- resource . id ,
71
- { status : 'cancelled' }
72
- ) . then ( result => {
73
- logger . info ( {
74
- component : 'JobEventHandler' ,
75
- context : 'cancelJob' ,
76
- message : `id: ${ result . id } resource booking got cancelled.`
77
- } )
78
- } ) )
79
- ] )
46
+ await Promise . all ( candidates . map ( candidate => JobCandidateService . partiallyUpdateJobCandidate (
47
+ helper . getAuditM2Muser ( ) ,
48
+ candidate . id ,
49
+ { status : 'cancelled' }
50
+ ) . then ( result => {
51
+ logger . info ( {
52
+ component : 'JobEventHandler' ,
53
+ context : 'cancelJob' ,
54
+ message : `id: ${ result . id } candidate got cancelled.`
55
+ } )
56
+ } ) ) )
80
57
}
81
58
82
59
/**
0 commit comments