Skip to content

Commit 9d4d436

Browse files
committed
Merge branch 'dev' into feature/payment-scheduler
2 parents 7c8cf21 + 7c67759 commit 9d4d436

File tree

11 files changed

+49
-20
lines changed

11 files changed

+49
-20
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@
103103
tc-taas-es-processor | 2021-04-09T21:20:21.469Z DEBUG no-kafka-client Subscribed to taas.workperiodpayment.update:0 offset 0 leader kafka:9093
104104
tc-taas-es-processor | 2021-04-09T21:20:21.470Z DEBUG no-kafka-client Subscribed to taas.workperiodpayment.delete:0 offset 0 leader kafka:9093
105105
tc-taas-es-processor | 2021-04-09T21:20:21.471Z DEBUG no-kafka-client Subscribed to taas.workperiodpayment.create:0 offset 0 leader kafka:9093
106+
tc-taas-es-processor | 2021-04-09T21:20:21.472Z DEBUG no-kafka-client Subscribed to taas.action.retry:0 offset 0 leader kafka:9093
106107
tc-taas-es-processor | 2021-04-09T21:20:21.473Z DEBUG no-kafka-client Subscribed to taas.job.update:0 offset 0 leader kafka:9093
107108
tc-taas-es-processor | 2021-04-09T21:20:21.474Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.update:0 offset 0 leader kafka:9093
108109
tc-taas-es-processor | [2021-04-09T21:20:21.475Z] app INFO : Initialized.......
109-
tc-taas-es-processor | [2021-04-09T21:20:21.479Z] app INFO : taas.job.create,taas.job.update,taas.job.delete,taas.jobcandidate.create,taas.jobcandidate.update,taas.jobcandidate.delete,taas.resourcebooking.create,taas.resourcebooking.update,taas.resourcebooking.delete,taas.workperiod.create,taas.workperiod.update,taas.workperiod.delete,taas.workperiodpayment.create,taas.workperiodpayment.update,taas.interview.requested,taas.interview.update,taas.interview.bulkUpdate,taas.role.requested,taas.role.update,taas.role.delete
110+
tc-taas-es-processor | [2021-04-09T21:20:21.479Z] app INFO : common.error.reporting,taas.job.create,taas.job.update,taas.job.delete,taas.jobcandidate.create,taas.jobcandidate.update,taas.jobcandidate.delete,taas.resourcebooking.create,taas.resourcebooking.update,taas.resourcebooking.delete,taas.workperiod.create,taas.workperiod.update,taas.workperiod.delete,taas.workperiodpayment.create,taas.workperiodpayment.update,taas.interview.requested,taas.interview.update,taas.interview.bulkUpdate,taas.role.requested,taas.role.update,taas.role.delete,taas.action.retry
110111
tc-taas-es-processor | [2021-04-09T21:20:21.480Z] app INFO : Kick Start.......
111112
tc-taas-es-processor | ********** Topcoder Health Check DropIn listening on port 3001
112113
tc-taas-es-processor | Topcoder Health Check DropIn started and ready to roll

config/default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ module.exports = {
140140
TAAS_ROLE_UPDATE_TOPIC: process.env.TAAS_ROLE_UPDATE_TOPIC || 'taas.role.update',
141141
// the delete role entity Kafka message topic
142142
TAAS_ROLE_DELETE_TOPIC: process.env.TAAS_ROLE_DELETE_TOPIC || 'taas.role.delete',
143+
// special kafka topics
144+
TAAS_ACTION_RETRY_TOPIC: process.env.TAAS_ACTION_RETRY_TOPIC || 'taas.action.retry',
143145

144146
// the Kafka message topic for sending email
145147
EMAIL_TOPIC: process.env.EMAIL_TOPIC || 'external.action.email',

local/kafka-client/topics.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ taas.interview.requested
2020
taas.interview.update
2121
taas.interview.bulkUpdate
2222
external.action.email
23+
taas.action.retry

src/common/helper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,9 @@ async function postEvent (topic, payload, options = {}) {
972972
'mime-type': 'application/json',
973973
payload
974974
}
975+
if (options.key) {
976+
message.key = options.key
977+
}
975978
await client.postEvent(message)
976979
await eventDispatcher.handleEvent(topic, { value: payload, options })
977980
}

src/controllers/JobController.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Controller for Job endpoints
33
*/
44
const HttpStatus = require('http-status-codes')
5+
const _ = require('lodash')
56
const service = require('../services/JobService')
67
const helper = require('../common/helper')
78

@@ -57,10 +58,8 @@ async function deleteJob (req, res) {
5758
* @param res the response
5859
*/
5960
async function searchJobs (req, res) {
60-
if (req.body && req.body.jobIds) {
61-
req.query.jobIds = req.body.jobIds
62-
}
63-
const result = await service.searchJobs(req.authUser, req.query)
61+
const query = { ...req.query, jobIds: _.get(req, 'body.jobIds', []) }
62+
const result = await service.searchJobs(req.authUser, query)
6463
helper.setResHeaders(req, res, result)
6564
res.send(result.result)
6665
}

src/eventHandlers/JobCandidateEventHandler.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,25 @@ async function inReviewJob (payload) {
2323
})
2424
return
2525
}
26-
await JobService.partiallyUpdateJob(
27-
helper.getAuditM2Muser(),
28-
job.id,
29-
{ status: 'in-review' }
30-
).then(result => {
31-
logger.info({
26+
if (payload.value.status === 'open') {
27+
await JobService.partiallyUpdateJob(
28+
helper.getAuditM2Muser(),
29+
job.id,
30+
{ status: 'in-review' }
31+
).then(result => {
32+
logger.info({
33+
component: 'JobCandidateEventHandler',
34+
context: 'inReviewJob',
35+
message: `id: ${result.id} job got in-review status.`
36+
})
37+
})
38+
} else {
39+
logger.debug({
3240
component: 'JobCandidateEventHandler',
3341
context: 'inReviewJob',
34-
message: `id: ${result.id} job got in-review status.`
42+
message: `id: ${payload.value.id} candidate is not in open status`
3543
})
36-
})
44+
}
3745
}
3846

3947
/**
@@ -46,6 +54,17 @@ async function processCreate (payload) {
4654
await inReviewJob(payload)
4755
}
4856

57+
/**
58+
* Process job candidate update event.
59+
*
60+
* @param {Object} payload the event payload
61+
* @returns {undefined}
62+
*/
63+
async function processUpdate (payload) {
64+
await inReviewJob(payload)
65+
}
66+
4967
module.exports = {
50-
processCreate
68+
processCreate,
69+
processUpdate
5170
}

src/eventHandlers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const logger = require('../common/logger')
1414
const TopicOperationMapping = {
1515
[config.TAAS_JOB_UPDATE_TOPIC]: JobEventHandler.processUpdate,
1616
[config.TAAS_JOB_CANDIDATE_CREATE_TOPIC]: JobCandidateEventHandler.processCreate,
17+
[config.TAAS_JOB_CANDIDATE_UPDATE_TOPIC]: JobCandidateEventHandler.processUpdate,
1718
[config.TAAS_RESOURCE_BOOKING_CREATE_TOPIC]: ResourceBookingEventHandler.processCreate,
1819
[config.TAAS_RESOURCE_BOOKING_UPDATE_TOPIC]: ResourceBookingEventHandler.processUpdate,
1920
[config.TAAS_RESOURCE_BOOKING_DELETE_TOPIC]: ResourceBookingEventHandler.processDelete,

src/services/WorkPeriodPaymentService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
8181
if (daysWorked === 0) {
8282
workPeriodPayment.amount = 0
8383
} else {
84-
workPeriodPayment.amount = _.round(memberRate * 5 / daysWorked, 2)
84+
workPeriodPayment.amount = _.round(memberRate * daysWorked / 5, 2)
8585
}
8686
}
8787

@@ -183,7 +183,7 @@ async function createWorkPeriodPayment (currentUser, workPeriodPayment) {
183183
const successResult = await _createSingleWorkPeriodPayment(wp, createdBy)
184184
result.push(successResult)
185185
} catch (e) {
186-
result.push(_.extend(wp, { error: { message: e.message, code: e.httpStatus } }))
186+
result.push(_.extend(_.pick(wp, 'workPeriodId'), { error: { message: e.message, code: e.httpStatus } }))
187187
}
188188
}
189189
return result

src/services/WorkPeriodService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ async function createWorkPeriod (currentUser, workPeriod) {
235235
}
236236
}
237237

238-
await helper.postEvent(config.TAAS_WORK_PERIOD_CREATE_TOPIC, created.toJSON())
238+
await helper.postEvent(config.TAAS_WORK_PERIOD_CREATE_TOPIC, created.toJSON(),{"key":workPeriod.resourceBookingId})
239239
return created.dataValues
240240
}
241241

@@ -289,7 +289,8 @@ async function updateWorkPeriod (currentUser, id, data) {
289289
}
290290
}
291291

292-
await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue })
292+
//await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue })
293+
await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), {oldValue: oldValue, "key":data.resourceBookingId})
293294
return updated.dataValues
294295
}
295296

test/unit/ResourceBookingService.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ describe('resourceBooking service test', () => {
447447
expect(esClientSearch.calledOnce).to.be.true
448448
expect(result).to.deep.eq(data.result)
449449
})
450-
it('T25:Search resource bookin from DB', async () => {
450+
it('T25:Search resource booking from DB', async () => {
451451
const data = testData.T25
452452
const ESClient = commonData.ESClient
453453
ESClient.search = () => {}
@@ -456,7 +456,7 @@ describe('resourceBooking service test', () => {
456456
return data.resourceBookingFindAll
457457
})
458458
const stubResourceBookingCount = sinon.stub(ResourceBooking, 'count').callsFake(async () => {
459-
return data.resourceBookingFindAll.length
459+
return data.resourceBookingCount
460460
})
461461
const result = await service.searchResourceBookings(commonData.userWithManagePermission, data.criteria)
462462
expect(esClientSearch.calledOnce).to.be.true

test/unit/common/ResourceBookingData.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,8 @@ const T25 = {
12291229
updatedAt: '2021-05-08T18:47:37.268Z'
12301230
}
12311231
],
1232+
resourceBookingCount: [{ id: 'fbe133dd-0e36-4d0c-8197-49307b13ce75', count: 1 },
1233+
{ id: '60e99790-8da0-4596-badc-29a06feb78a0', count: 1 }],
12321234
criteria: {},
12331235
result: {
12341236
fromDb: true,

0 commit comments

Comments
 (0)