From d3e868dc90816292bd5167146179949bd9f3c391 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Thu, 30 Sep 2021 21:32:53 +0800 Subject: [PATCH 1/3] update:support specialJob params --- data/demo-data.json | 2 ++ src/services/JobService.js | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/data/demo-data.json b/data/demo-data.json index bc384902..94eb958f 100644 --- a/data/demo-data.json +++ b/data/demo-data.json @@ -25,6 +25,7 @@ "hoursPerWeek": 20, "jobLocation": "Any location", "jobTimezone": "GMT", + "featured": true, "currency": "USD", "roleIds": null, "createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c", @@ -44,6 +45,7 @@ "resourceType": "Dummy Resource Type", "rateType": "hourly", "workload": "full-time", + "showInHotList": true, "skills": [ "23e00d92-207a-4b5b-b3c9-4c5662644941", "7d076384-ccf6-4e43-a45d-1b24b1e624aa", diff --git a/src/services/JobService.js b/src/services/JobService.js index 3e13519d..b5851c00 100644 --- a/src/services/JobService.js +++ b/src/services/JobService.js @@ -430,7 +430,7 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false } const page = criteria.page > 0 ? criteria.page : 1 let perPage - if (options.returnAll) { + if (options.returnAll || criteria.specialJob) { // To simplify the logic we are use a very large number for perPage // because in practice there could hardly be so many records to be returned.(also consider we are using filters in the meantime) // the number is limited by `index.max_result_window`, its default value is 10000, see @@ -480,7 +480,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false } 'status', 'minSalary', 'maxSalary', - 'jobLocation' + 'jobLocation', + 'specialJob' ]), (value, key) => { let must if (key === 'description' || key === 'title') { @@ -512,6 +513,27 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false } } } } + } else if (key === 'specialJob') { + if (value === true) { + must = { + bool: { + should: [ + { + term: { + featured: value + } + }, + { + term: { + showInHotList: value + } + } + ] + } + } + } else { + return true + } } else { must = { term: { @@ -689,7 +711,8 @@ searchJobs.schema = Joi.object().keys({ bodySkills: Joi.array().items(Joi.string().uuid()), minSalary: Joi.number().integer(), maxSalary: Joi.number().integer(), - jobLocation: Joi.string() + jobLocation: Joi.string(), + specialJob: Joi.boolean() }).required(), options: Joi.object() }).required() From 5bc212228bb1c5beafb6397fb46cc717c48e0e1e Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Thu, 30 Sep 2021 21:41:23 +0800 Subject: [PATCH 2/3] update: swagger to match the API --- docs/swagger.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 9f483b06..600cea98 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -207,6 +207,12 @@ paths: type: string enum: ["sourcing", "in-review", "assigned", "closed", "cancelled"] description: The rate type. + - in: query + name: specialJob + required: false + schema: + type: boolean + description: Load all featured and showInHotList jobs at once requestBody: content: application/json: From 9145a5cf06ac11ec8e130a983c7f3e65d9175ac0 Mon Sep 17 00:00:00 2001 From: LieutenantRoger Date: Thu, 30 Sep 2021 21:47:14 +0800 Subject: [PATCH 3/3] update:swagger instruction --- docs/swagger.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 600cea98..98991993 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -212,7 +212,7 @@ paths: required: false schema: type: boolean - description: Load all featured and showInHotList jobs at once + description: When passing true, the API will load all featured and showInHotList jobs at once requestBody: content: application/json: