Skip to content

Commit 006b109

Browse files
Support to special=false and featured query param (#569)
* special job false * db special false * ci:deploying * support featured search * restore ci
1 parent f5f172e commit 006b109

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

data/demo-data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,7 @@
13251325
"externalId": "300234321",
13261326
"resume": "http://example.com",
13271327
"remark": "excellent",
1328+
"featured": null,
13281329
"createdBy": "00000000-0000-0000-0000-000000000000",
13291330
"updatedBy": "00000000-0000-0000-0000-000000000000",
13301331
"createdAt": "2021-05-09T21:15:02.183Z",

docs/swagger.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ paths:
213213
schema:
214214
type: boolean
215215
description: When passing true, the API will load all featured and showInHotList jobs at once
216+
- in: query
217+
name: featured
218+
required: false
219+
schema:
220+
type: boolean
221+
description: The featured jobs
216222
requestBody:
217223
content:
218224
application/json:

src/services/JobService.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
481481
'minSalary',
482482
'maxSalary',
483483
'jobLocation',
484-
'specialJob'
484+
'specialJob',
485+
'featured'
485486
]), (value, key) => {
486487
let must
487488
if (key === 'description' || key === 'title') {
@@ -532,7 +533,22 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
532533
}
533534
}
534535
} else {
535-
return true
536+
must = {
537+
bool: {
538+
must: [
539+
{
540+
term: {
541+
featured: value
542+
}
543+
},
544+
{
545+
term: {
546+
showInHotList: value
547+
}
548+
}
549+
]
550+
}
551+
}
536552
}
537553
} else {
538554
must = {
@@ -601,7 +617,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
601617
'resourceType',
602618
'rateType',
603619
'workload',
604-
'status'
620+
'status',
621+
'featured'
605622
]), (value, key) => {
606623
filter[Op.and].push({ [key]: value })
607624
})
@@ -674,6 +691,10 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
674691
]
675692
})
676693
}
694+
if (criteria.specialJob === false) {
695+
filter[Op.and].push({ featured: false })
696+
filter[Op.and].push({ showInHotList: false })
697+
}
677698
const jobs = await Job.findAll({
678699
where: filter,
679700
offset: ((page - 1) * perPage),
@@ -720,7 +741,8 @@ searchJobs.schema = Joi.object().keys({
720741
minSalary: Joi.number().integer(),
721742
maxSalary: Joi.number().integer(),
722743
jobLocation: Joi.string(),
723-
specialJob: Joi.boolean()
744+
specialJob: Joi.boolean(),
745+
featured: Joi.boolean()
724746
}).required(),
725747
options: Joi.object()
726748
}).required()

0 commit comments

Comments
 (0)