From 6a3dc48dcdbe3ba6723e67204bf3a529abe9c89b Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Thu, 23 Jun 2022 09:39:43 +0800 Subject: [PATCH 1/3] redeploying original --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index fbc92f8..8dfe779 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -122,6 +122,7 @@ workflows: branches: only: - develop + - fix-listmemberchallenges # Production builds are exectuted only on tagged commits to the testing # master branch. From e532554a5af49a067cc9f4927aee4a921eacaadc Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Mon, 27 Jun 2022 12:07:58 +0800 Subject: [PATCH 2/3] redeploy resource fix --- config/default.js | 1 + src/services/ResourceService.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config/default.js b/config/default.js index 503eedf..fade308 100644 --- a/config/default.js +++ b/config/default.js @@ -7,6 +7,7 @@ module.exports = { PORT: process.env.PORT || 3000, API_VERSION: process.env.API_VERSION || 'v5', DEFAULT_PAGE_SIZE: process.env.DEFAULT_PAGE_SIZE || 1000, + MAX_ELASTIC_SEARCH_RECORDS_SIZE: process.env.MAX_ELASTIC_SEARCH_RECORDS_SIZE || 10000, // used to properly set the header response to api calls for services behind a load balancer API_BASE_URL: process.env.API_BASE_URL || `http://localhost:3000`, diff --git a/src/services/ResourceService.js b/src/services/ResourceService.js index 4016d99..199fde7 100644 --- a/src/services/ResourceService.js +++ b/src/services/ResourceService.js @@ -446,7 +446,23 @@ async function listChallengesByMember (memberId, criteria) { } }) - const docs = await searchES(mustQuery, perPage, page) + let docs = { + hits: { + total: 0, + hits: [] + } + } + + if (perPage * page <= config.MAX_ELASTIC_SEARCH_RECORDS_SIZE) { + docs = await searchES(mustQuery, perPage, page) + } else { + throw new errors.BadRequestError(` + ES pagination params: + page ${page}, + perPage: ${perPage} + exceeds the max search window:${config.MAX_ELASTIC_SEARCH_RECORDS_SIZE}` + ) + } // Extract data from hits let result = _.map(docs.hits.hits, item => item._source) From 98f0666841c23e83cd76e65e2c52af48edc131fb Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Fri, 22 Jul 2022 00:08:25 +0800 Subject: [PATCH 3/3] reset ci --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8dfe779..fbc92f8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -122,7 +122,6 @@ workflows: branches: only: - develop - - fix-listmemberchallenges # Production builds are exectuted only on tagged commits to the testing # master branch.