Skip to content

fix #337 #341

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 2 commits into from
Jun 14, 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 src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ function setResHeaders (req, res, result) {
res.set('X-Per-Page', result.perPage)
res.set('X-Total', result.total)
res.set('X-Total-Pages', totalPages)
res.set('X-Data-Source', result.fromDb ? 'database' : 'elasticsearch')
// set Link header
if (totalPages > 0) {
let link = `<${getPageLink(req, 1)}>; rel="first", <${getPageLink(
Expand Down
3 changes: 2 additions & 1 deletion src/services/InterviewService.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,10 @@ async function searchInterviews (currentUser, jobCandidateId, criteria) {
limit: perPage,
order: [[criteria.sortBy, criteria.sortOrder]]
})
const total = await Interview.count({ where: filter })
return {
fromDb: true,
total: interviews.length,
total,
page,
perPage,
result: _.map(interviews, interview => interview.dataValues)
Expand Down
3 changes: 2 additions & 1 deletion src/services/JobCandidateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ async function searchJobCandidates (currentUser, criteria) {
limit: perPage,
order: [[criteria.sortBy, criteria.sortOrder]]
})
const total = await JobCandidate.count({ where: filter })
return {
fromDb: true,
total: jobCandidates.length,
total,
page,
perPage,
result: _.map(jobCandidates, jobCandidate => _.omit(jobCandidate.dataValues, omitList))
Expand Down
3 changes: 2 additions & 1 deletion src/services/JobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,10 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
required: false
}]
})
const total = await Job.count({ where: filter })
return {
fromDb: true,
total: jobs.length,
total,
page,
perPage,
result: _.map(jobs, job => job.dataValues)
Expand Down
3 changes: 2 additions & 1 deletion src/services/WorkPeriodPaymentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,10 @@ async function searchWorkPeriodPayments (currentUser, criteria, options = { retu
limit: perPage,
order: [[criteria.sortBy, criteria.sortOrder]]
})
const total = await WorkPeriodPayment.count({ where: filter })
return {
fromDb: true,
total: workPeriodPayments.length,
total,
page,
perPage,
result: workPeriodPayments
Expand Down
3 changes: 2 additions & 1 deletion src/services/WorkPeriodService.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,10 @@ async function searchWorkPeriods (currentUser, criteria, options = { returnAll:
}]
}
const workPeriods = await WorkPeriod.findAll(queryCriteria)
const total = await WorkPeriod.count({ where: filter })
return {
fromDb: true,
total: workPeriods.length,
total,
page,
perPage,
result: workPeriods
Expand Down