Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/demo-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"hoursPerWeek": 20,
"jobLocation": "Any location",
"jobTimezone": "GMT",
"featured": true,
"currency": "USD",
"roleIds": null,
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
Expand All @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: When passing true, the API will load all featured and showInHotList jobs at once
requestBody:
content:
application/json:
Expand Down
29 changes: 26 additions & 3 deletions src/services/JobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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()
Expand Down