From 4484412954cfcf656d34b84da99fa1a3c50a7805 Mon Sep 17 00:00:00 2001 From: nkumar-topcoder <33625707+nkumar-topcoder@users.noreply.github.com> Date: Wed, 19 May 2021 15:27:34 +0530 Subject: [PATCH 1/4] BA is to string [skip ci] BA is to string [skip ci] --- src/services/PaymentService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/PaymentService.js b/src/services/PaymentService.js index 3143b936..2dcd8b04 100644 --- a/src/services/PaymentService.js +++ b/src/services/PaymentService.js @@ -84,7 +84,7 @@ async function createChallenge (challenge, token) { if (challenge.billingAccountId) { body.billing = { - billingAccountId: challenge.billingAccountId, + billingAccountId: _.toString(challenge.billingAccountId), markup: 0 // for TaaS payments we always use 0 markup } } From b26f1f9968f2fb5d8f47f218b8674d6f252d4059 Mon Sep 17 00:00:00 2001 From: nkumar-topcoder <33625707+nkumar-topcoder@users.noreply.github.com> Date: Wed, 19 May 2021 15:36:55 +0530 Subject: [PATCH 2/4] BA number to string --- src/services/PaymentService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/PaymentService.js b/src/services/PaymentService.js index 2dcd8b04..d06ad671 100644 --- a/src/services/PaymentService.js +++ b/src/services/PaymentService.js @@ -85,7 +85,7 @@ async function createChallenge (challenge, token) { if (challenge.billingAccountId) { body.billing = { billingAccountId: _.toString(challenge.billingAccountId), - markup: 0 // for TaaS payments we always use 0 markup + markup: 0 // for TaaS payments we always use 0 markup } } try { From a25254444e2396fd12e36d54931624ce1948f9e9 Mon Sep 17 00:00:00 2001 From: dengjun Date: Thu, 15 Jul 2021 23:14:41 +0800 Subject: [PATCH 3/4] search candidates API --- src/controllers/JobCandidateController.js | 4 +++- src/services/JobCandidateService.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/controllers/JobCandidateController.js b/src/controllers/JobCandidateController.js index 4f81c7ec..a6a31fbd 100644 --- a/src/controllers/JobCandidateController.js +++ b/src/controllers/JobCandidateController.js @@ -2,6 +2,7 @@ * Controller for JobCandidate endpoints */ const HttpStatus = require('http-status-codes') +const _ = require('lodash') const service = require('../services/JobCandidateService') const helper = require('../common/helper') @@ -57,7 +58,8 @@ async function deleteJobCandidate (req, res) { * @param res the response */ async function searchJobCandidates (req, res) { - const result = await service.searchJobCandidates(req.authUser, req.query) + const query = { ...req.query, statuses: _.get(req, 'body.statuses', []) } + const result = await service.searchJobCandidates(req.authUser, query) helper.setResHeaders(req, res, result) res.send(result.result) } diff --git a/src/services/JobCandidateService.js b/src/services/JobCandidateService.js index a46917aa..b08922e4 100644 --- a/src/services/JobCandidateService.js +++ b/src/services/JobCandidateService.js @@ -283,6 +283,15 @@ async function searchJobCandidates (currentUser, criteria) { } }) }) + + // if criteria contains statuses, filter statuses with this value + if (criteria.statuses && criteria.statuses.length > 0) { + esQuery.body.query.bool.filter.push({ + terms: { + status: criteria.statuses + } + }) + } logger.debug({ component: 'JobCandidateService', context: 'searchJobCandidates', message: `Query: ${JSON.stringify(esQuery)}` }) const { body } = await esClient.search(esQuery) @@ -301,10 +310,13 @@ async function searchJobCandidates (currentUser, criteria) { logger.logFullError(err, { component: 'JobCandidateService', context: 'searchJobCandidates' }) } logger.info({ component: 'JobCandidateService', context: 'searchJobCandidates', message: 'fallback to DB query' }) - const filter = {} + const filter = { [Op.and]: [] } _.each(_.pick(criteria, ['jobId', 'userId', 'status', 'externalId']), (value, key) => { filter[Op.and].push({ [key]: value }) }) + if (criteria.statuses && criteria.statuses.length > 0) { + filter[Op.and].push({ status: criteria.statuses }) + } // include interviews if user has permission const include = [] @@ -340,6 +352,7 @@ searchJobCandidates.schema = Joi.object().keys({ jobId: Joi.string().uuid(), userId: Joi.string().uuid(), status: Joi.jobCandidateStatus(), + statuses: Joi.array().items(Joi.jobCandidateStatus()), externalId: Joi.string() }).required() }).required() From 42261e9b93350061f57a392c35c387f1a33d5ddd Mon Sep 17 00:00:00 2001 From: dengjun Date: Fri, 16 Jul 2021 09:41:52 +0800 Subject: [PATCH 4/4] update swagger --- docs/swagger.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 8156b661..7dd9c492 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -624,6 +624,11 @@ paths: schema: type: string description: The external id. + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/JobCandidateSearchBody" responses: "200": description: OK @@ -3996,6 +4001,14 @@ components: type: string example: "topcoder user" description: "The user who updated the job last time.(Will get the user info from the token)" + JobCandidateSearchBody: + properties: + statuses: + type: array + items: + type: string + enum: ["open", "placed", "selected", "client rejected - screening", "client rejected - interview", "rejected - other", "cancelled", "interview", "topcoder-rejected", "applied", "rejected-pre-screen", "skills-test", "phone-screen", "job-closed", "offered"] + description: "The array of job Candidates status" JobCandidateRequestBody: required: - jobId