From 8ae0db251e7db9d47b87cf74a6cc761f4f321cfd Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Thu, 3 Mar 2022 02:07:21 +0800 Subject: [PATCH 1/3] add message key --- package-lock.json | 5 +++++ src/common/helper.js | 11 ++++++++--- src/services/ChallengeService.js | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 346fb807..6c4d59f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1089,6 +1089,11 @@ "esutils": "^2.0.2" } }, + "dotenv": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", + "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==" + }, "dtrace-provider": { "version": "0.8.8", "resolved": "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.8.8.tgz", 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 f4481eadf8d06493f335eafdeb8d7b773d3b3f42 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Thu, 3 Mar 2022 14:10:22 +0800 Subject: [PATCH 2/3] deploy issue message with key --- .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 e6331baf8457643e068de9636350bb6e2097bd40 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Thu, 3 Mar 2022 16:13:27 +0800 Subject: [PATCH 3/3] restore ci --- .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.