From 07d558745df51d89caf1f24de277b632d9bcace4 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Fri, 4 Mar 2022 12:33:28 +0800 Subject: [PATCH 1/4] Revert "Resolve Duplicate Payment issue" --- package-lock.json | 5 ----- src/common/helper.js | 11 +++-------- src/services/ChallengeService.js | 6 +----- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6c4d59f8..346fb807 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1089,11 +1089,6 @@ "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 7eb3a96d..9f1ca2a4 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -764,21 +764,16 @@ 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, options = {}) { +async function postBusEvent (topic, payload) { const client = getBusApiClient() - const message = { + await client.postEvent({ 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 2ba26ebe..3fae50fe 100644 --- a/src/services/ChallengeService.js +++ b/src/services/ChallengeService.js @@ -1951,11 +1951,7 @@ async function update (currentUser, challengeId, data, isFull) { // post bus event logger.debug(`Post Bus Event: ${constants.Topics.ChallengeUpdated} ${JSON.stringify(challenge)}`) - const options = {} - if (challenge.status == 'Completed') { - options.key = `${challenge.id}:${challenge.status}` - } - await helper.postBusEvent(constants.Topics.ChallengeUpdated, challenge, options) + await helper.postBusEvent(constants.Topics.ChallengeUpdated, challenge) if (phasesHaveBeenModified === true && _.get(challenge, 'legacy.useSchedulingAPI')) { await helper.postBusEvent(config.SCHEDULING_TOPIC, { id: challengeId }) } From a78b60bc4b599eb7ebd118ba0aad6828aae71769 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Fri, 4 Mar 2022 19:37:19 +0800 Subject: [PATCH 2/4] 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 3/4] 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 4/4] 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.