Skip to content

[Ready Release] Gigs listing - Jobs special false and featured query param #570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 13, 2021
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
1 change: 1 addition & 0 deletions data/demo-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,7 @@
"externalId": "300234321",
"resume": "http://example.com",
"remark": "excellent",
"featured": null,
"createdBy": "00000000-0000-0000-0000-000000000000",
"updatedBy": "00000000-0000-0000-0000-000000000000",
"createdAt": "2021-05-09T21:15:02.183Z",
Expand Down
6 changes: 6 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ paths:
schema:
type: boolean
description: When passing true, the API will load all featured and showInHotList jobs at once
- in: query
name: featured
required: false
schema:
type: boolean
description: The featured jobs
requestBody:
content:
application/json:
Expand Down
30 changes: 26 additions & 4 deletions src/services/JobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
'minSalary',
'maxSalary',
'jobLocation',
'specialJob'
'specialJob',
'featured'
]), (value, key) => {
let must
if (key === 'description' || key === 'title') {
Expand Down Expand Up @@ -532,7 +533,22 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
}
}
} else {
return true
must = {
bool: {
must: [
{
term: {
featured: value
}
},
{
term: {
showInHotList: value
}
}
]
}
}
}
} else {
must = {
Expand Down Expand Up @@ -601,7 +617,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
'resourceType',
'rateType',
'workload',
'status'
'status',
'featured'
]), (value, key) => {
filter[Op.and].push({ [key]: value })
})
Expand Down Expand Up @@ -674,6 +691,10 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
]
})
}
if (criteria.specialJob === false) {
filter[Op.and].push({ featured: false })
filter[Op.and].push({ showInHotList: false })
}
const jobs = await Job.findAll({
where: filter,
offset: ((page - 1) * perPage),
Expand Down Expand Up @@ -720,7 +741,8 @@ searchJobs.schema = Joi.object().keys({
minSalary: Joi.number().integer(),
maxSalary: Joi.number().integer(),
jobLocation: Joi.string(),
specialJob: Joi.boolean()
specialJob: Joi.boolean(),
featured: Joi.boolean()
}).required(),
options: Joi.object()
}).required()
Expand Down