Skip to content

fix: remove jobIds from query #310

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

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions src/controllers/JobController.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ async function searchJobs (req, res) {
req.query.jobIds = req.body.jobIds
}
const result = await service.searchJobs(req.authUser, req.query)
if (req.query.jobIds) {
delete req.query.jobIds
}
Comment on lines 61 to +66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current logic to add and then to delete fields is a bit hard to follow. It would be nice if logic would more straightforward, for example like this:

const query = {
   ...req.query,
   // we can pass jobIds in `body` or in `query`
   jobIds: _.get(req, 'body.jobIds', req.query.jobIds)
}
const result = await service.searchJobs(req.authUser, query)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, maybe simply check body for it, if jobIds are not present, we can avoid to pass jobIds to the criteria or pass an empty array. By looking at the service method, seems both would be fine.

helper.setResHeaders(req, res, result)
res.send(result.result)
}
Expand Down