diff --git a/src/eventHandlers/JobCandidateEventHandler.js b/src/eventHandlers/JobCandidateEventHandler.js index c199cb7d..8780ab08 100644 --- a/src/eventHandlers/JobCandidateEventHandler.js +++ b/src/eventHandlers/JobCandidateEventHandler.js @@ -23,17 +23,25 @@ async function inReviewJob (payload) { }) return } - await JobService.partiallyUpdateJob( - helper.getAuditM2Muser(), - job.id, - { status: 'in-review' } - ).then(result => { - logger.info({ + if (payload.value.status === 'open') { + await JobService.partiallyUpdateJob( + helper.getAuditM2Muser(), + job.id, + { status: 'in-review' } + ).then(result => { + logger.info({ + component: 'JobCandidateEventHandler', + context: 'inReviewJob', + message: `id: ${result.id} job got in-review status.` + }) + }) + } else { + logger.debug({ component: 'JobCandidateEventHandler', context: 'inReviewJob', - message: `id: ${result.id} job got in-review status.` + message: `id: ${payload.value.id} candidate is not in open status` }) - }) + } } /** @@ -46,6 +54,17 @@ async function processCreate (payload) { await inReviewJob(payload) } +/** + * Process job candidate update event. + * + * @param {Object} payload the event payload + * @returns {undefined} + */ +async function processUpdate (payload) { + await inReviewJob(payload) +} + module.exports = { - processCreate + processCreate, + processUpdate } diff --git a/src/eventHandlers/index.js b/src/eventHandlers/index.js index 6e0ec2a8..c88ef929 100644 --- a/src/eventHandlers/index.js +++ b/src/eventHandlers/index.js @@ -14,6 +14,7 @@ const logger = require('../common/logger') const TopicOperationMapping = { [config.TAAS_JOB_UPDATE_TOPIC]: JobEventHandler.processUpdate, [config.TAAS_JOB_CANDIDATE_CREATE_TOPIC]: JobCandidateEventHandler.processCreate, + [config.TAAS_JOB_CANDIDATE_UPDATE_TOPIC]: JobCandidateEventHandler.processUpdate, [config.TAAS_RESOURCE_BOOKING_CREATE_TOPIC]: ResourceBookingEventHandler.processCreate, [config.TAAS_RESOURCE_BOOKING_UPDATE_TOPIC]: ResourceBookingEventHandler.processUpdate, [config.TAAS_RESOURCE_BOOKING_DELETE_TOPIC]: ResourceBookingEventHandler.processDelete,