Skip to content

Commit a0d5740

Browse files
Update jobs to support search specialJob (#562)
* update:support specialJob params * update: swagger to match the API * update:swagger instruction
1 parent 8e5e058 commit a0d5740

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

data/demo-data.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"hoursPerWeek": 20,
2626
"jobLocation": "Any location",
2727
"jobTimezone": "GMT",
28+
"featured": true,
2829
"currency": "USD",
2930
"roleIds": null,
3031
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
@@ -44,6 +45,7 @@
4445
"resourceType": "Dummy Resource Type",
4546
"rateType": "hourly",
4647
"workload": "full-time",
48+
"showInHotList": true,
4749
"skills": [
4850
"23e00d92-207a-4b5b-b3c9-4c5662644941",
4951
"7d076384-ccf6-4e43-a45d-1b24b1e624aa",

docs/swagger.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ paths:
207207
type: string
208208
enum: ["sourcing", "in-review", "assigned", "closed", "cancelled"]
209209
description: The rate type.
210+
- in: query
211+
name: specialJob
212+
required: false
213+
schema:
214+
type: boolean
215+
description: When passing true, the API will load all featured and showInHotList jobs at once
210216
requestBody:
211217
content:
212218
application/json:

src/services/JobService.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
430430

431431
const page = criteria.page > 0 ? criteria.page : 1
432432
let perPage
433-
if (options.returnAll) {
433+
if (options.returnAll || criteria.specialJob) {
434434
// To simplify the logic we are use a very large number for perPage
435435
// because in practice there could hardly be so many records to be returned.(also consider we are using filters in the meantime)
436436
// 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 }
480480
'status',
481481
'minSalary',
482482
'maxSalary',
483-
'jobLocation'
483+
'jobLocation',
484+
'specialJob'
484485
]), (value, key) => {
485486
let must
486487
if (key === 'description' || key === 'title') {
@@ -512,6 +513,27 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
512513
}
513514
}
514515
}
516+
} else if (key === 'specialJob') {
517+
if (value === true) {
518+
must = {
519+
bool: {
520+
should: [
521+
{
522+
term: {
523+
featured: value
524+
}
525+
},
526+
{
527+
term: {
528+
showInHotList: value
529+
}
530+
}
531+
]
532+
}
533+
}
534+
} else {
535+
return true
536+
}
515537
} else {
516538
must = {
517539
term: {
@@ -689,7 +711,8 @@ searchJobs.schema = Joi.object().keys({
689711
bodySkills: Joi.array().items(Joi.string().uuid()),
690712
minSalary: Joi.number().integer(),
691713
maxSalary: Joi.number().integer(),
692-
jobLocation: Joi.string()
714+
jobLocation: Joi.string(),
715+
specialJob: Joi.boolean()
693716
}).required(),
694717
options: Joi.object()
695718
}).required()

0 commit comments

Comments
 (0)