Skip to content

Commit f7706b7

Browse files
authored
Merge pull request #338 from topcoder-platform/feature/topic-bus-key
Feature/topic bus key
2 parents cc7749b + 6d4a177 commit f7706b7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/common/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,8 @@ async function postEvent (topic, payload, options = {}) {
973973
payload
974974
}
975975
if (options.key) {
976-
message.key = options.key
977-
}
976+
message.key = options.key
977+
}
978978
await client.postEvent(message)
979979
await eventDispatcher.handleEvent(topic, { value: payload, options })
980980
}

src/services/WorkPeriodPaymentService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
9696
}
9797
}
9898

99-
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_CREATE_TOPIC, created.toJSON())
99+
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_CREATE_TOPIC, created.toJSON(), { key: `workPeriodPayment.billingAccountId:${workPeriodPayment.billingAccountId}` })
100100
return created.dataValues
101101
}
102102

@@ -234,7 +234,7 @@ async function updateWorkPeriodPayment (currentUser, id, data) {
234234
}
235235
}
236236

237-
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue })
237+
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue, key: `workPeriodPayment.billingAccountId:${updated.billingAccountId}` })
238238
return updated.dataValues
239239
}
240240

src/services/WorkPeriodService.js

Lines changed: 5 additions & 5 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(),{"key":workPeriod.resourceBookingId})
238+
await helper.postEvent(config.TAAS_WORK_PERIOD_CREATE_TOPIC, created.toJSON(), { key: `resourceBooking.id:${workPeriod.resourceBookingId}` })
239239
return created.dataValues
240240
}
241241

@@ -289,8 +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 })
293-
await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), {oldValue: oldValue, "key":data.resourceBookingId})
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: `resourceBooking.id:${data.resourceBookingId}` })
294294
return updated.dataValues
295295
}
296296

@@ -364,9 +364,9 @@ async function deleteWorkPeriod (currentUser, id) {
364364
workPeriodId: id
365365
}
366366
})
367-
await Promise.all(workPeriod.payments.map(({ id }) => helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_DELETE_TOPIC, { id })))
367+
await Promise.all(workPeriod.payments.map(({ id, billingAccountId }) => helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_DELETE_TOPIC, { id }, { key: `workPeriodPayment.billingAccountId:${billingAccountId}` })))
368368
await workPeriod.destroy()
369-
await helper.postEvent(config.TAAS_WORK_PERIOD_DELETE_TOPIC, { id })
369+
await helper.postEvent(config.TAAS_WORK_PERIOD_DELETE_TOPIC, { id }, { key: `resourceBooking.id:${workPeriod.resourceBookingId}` })
370370
}
371371

372372
deleteWorkPeriod.schema = Joi.object().keys({

0 commit comments

Comments
 (0)