From 1c5ce624b5b68899a6ac8494e7fd66d837d29db3 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Wed, 28 Aug 2024 10:36:02 +1000 Subject: [PATCH 1/3] Minor tweaks for ES to OS transition for OpenSearch consolidation --- README.md | 1 + config/default.js | 2 +- src/common/helper.js | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f2453a51..8e55d566 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ The following parameters can be set in config files or in env variables: - ES.ES_INDEX: Elasticsearch index name - ES.ES_REFRESH: Elasticsearch refresh method. Default to string `true`(i.e. refresh immediately) - FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes +- OPENSEARCH: Flag to use Opensearch NPM instead of Elasticsearch - RESOURCES_API_URL: TC resources API base URL - GROUPS_API_URL: TC groups API base URL - PROJECTS_API_URL: TC projects API base URL diff --git a/config/default.js b/config/default.js index 4727e58e..f41d359f 100644 --- a/config/default.js +++ b/config/default.js @@ -40,7 +40,7 @@ module.exports = { ES: { // above AWS_REGION is used if we use AWS ES - HOST: process.env.ES_HOST || "localhost:9200", + HOST: process.env.OS_HOST || "localhost:9200", API_VERSION: process.env.ES_API_VERSION || "6.8", OPENSEARCH: process.env.OPENSEARCH || "false", ES_INDEX: process.env.ES_INDEX || "challenge", diff --git a/src/common/helper.js b/src/common/helper.js index b6355f29..eaaa0579 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -17,7 +17,7 @@ const HttpStatus = require("http-status-codes"); const xss = require("xss"); const logger = require("./logger"); -const { Client: ESClient } = require("@opensearch-project/opensearch"); +const { Client: OSClient } = require("@opensearch-project/opensearch"); const elasticsearch = require("elasticsearch"); const projectHelper = require("./project-helper"); @@ -734,7 +734,7 @@ function getESClient() { }); } } else { - esClient = new ESClient({ + esClient = new OSClient({ node: esHost, ssl: { rejectUnauthorized: false, From ea6cd74427bb3dfd0807135ef9532c47513691fc Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Wed, 28 Aug 2024 11:02:46 +1000 Subject: [PATCH 2/3] Didn't need this change --- config/default.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.js b/config/default.js index f41d359f..4727e58e 100644 --- a/config/default.js +++ b/config/default.js @@ -40,7 +40,7 @@ module.exports = { ES: { // above AWS_REGION is used if we use AWS ES - HOST: process.env.OS_HOST || "localhost:9200", + HOST: process.env.ES_HOST || "localhost:9200", API_VERSION: process.env.ES_API_VERSION || "6.8", OPENSEARCH: process.env.OPENSEARCH || "false", ES_INDEX: process.env.ES_INDEX || "challenge", From 968a3f69af9fd703bc248a6174af2a2a353d8dd3 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Fri, 8 Nov 2024 11:45:17 +1100 Subject: [PATCH 3/3] Ensure we fill in the billing details if a project ID is provided, regardless of the timeline template ID --- src/services/ChallengeService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/ChallengeService.js b/src/services/ChallengeService.js index d11390a3..ca0d2d9a 100644 --- a/src/services/ChallengeService.js +++ b/src/services/ChallengeService.js @@ -884,7 +884,7 @@ async function createChallenge(currentUser, challenge, userToken) { } /** Ensure project exists, and set direct project id, billing account id & markup */ - if (challengeHelper.isProjectIdRequired(challenge.timelineTemplateId)) { + if (challengeHelper.isProjectIdRequired(challenge.timelineTemplateId) || challenge.projectId) { const { projectId } = challenge; const { directProjectId } = await projectHelper.getProject(projectId, currentUser);