From a78b60bc4b599eb7ebd118ba0aad6828aae71769 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Fri, 4 Mar 2022 19:37:19 +0800 Subject: [PATCH 1/3] add key --- src/common/helper.js | 11 ++++++++--- src/services/ChallengeService.js | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/helper.js b/src/common/helper.js index 9f1ca2a4..7eb3a96d 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -764,16 +764,21 @@ function getBusApiClient () { * Post bus event. * @param {String} topic the event topic * @param {Object} payload the event payload + * @param {Object} options the extra options to the message */ -async function postBusEvent (topic, payload) { +async function postBusEvent (topic, payload, options = {}) { const client = getBusApiClient() - await client.postEvent({ + const message = { topic, originator: constants.EVENT_ORIGINATOR, timestamp: new Date().toISOString(), 'mime-type': constants.EVENT_MIME_TYPE, payload - }) + } + if (options.key) { + message.key = options.key + } + await client.postEvent(message) } /** diff --git a/src/services/ChallengeService.js b/src/services/ChallengeService.js index 3fae50fe..2ba26ebe 100644 --- a/src/services/ChallengeService.js +++ b/src/services/ChallengeService.js @@ -1951,7 +1951,11 @@ async function update (currentUser, challengeId, data, isFull) { // post bus event logger.debug(`Post Bus Event: ${constants.Topics.ChallengeUpdated} ${JSON.stringify(challenge)}`) - await helper.postBusEvent(constants.Topics.ChallengeUpdated, challenge) + const options = {} + if (challenge.status == 'Completed') { + options.key = `${challenge.id}:${challenge.status}` + } + await helper.postBusEvent(constants.Topics.ChallengeUpdated, challenge, options) if (phasesHaveBeenModified === true && _.get(challenge, 'legacy.useSchedulingAPI')) { await helper.postBusEvent(config.SCHEDULING_TOPIC, { id: challengeId }) } From 4b19d5a2b7e2da9eb4de36ef5ba8b53fbbf9fbe3 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Fri, 4 Mar 2022 19:56:12 +0800 Subject: [PATCH 2/3] ci:deploying --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0c857aaf..30bbfcf6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -69,7 +69,7 @@ workflows: filters: branches: only: - - develop + - issue_dup # Production builds are exectuted only on tagged commits to the # master branch. From 19ce91b5aa49cd681d28599c1528b5bb232925a3 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Fri, 4 Mar 2022 20:56:48 +0800 Subject: [PATCH 3/3] ci:dev --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 30bbfcf6..0c857aaf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -69,7 +69,7 @@ workflows: filters: branches: only: - - issue_dup + - develop # Production builds are exectuted only on tagged commits to the # master branch.