-
Notifications
You must be signed in to change notification settings - Fork 1
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
#169258648 User can search trip requests by preference #53
Conversation
869934a
to
1fb90f3
Compare
1fb90f3
to
2a7355a
Compare
4581f9f
to
fb4014a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job @ivymwende , I left a comment, please view it and we will be good to go.
return Response.errorMessage(req, res, 'You provided an invalid search query key(s) parameter.Your search key should be either originId, destinationId, startDate, returnDate, firstName, status, or tripType', 400); | ||
} | ||
|
||
if (query.originId === '' || query.destinationId === '' || query.startDate === '' || query.returnDate === '' || query.firstName === '' || query.tripType === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ivymwende , lets make this line shorter ie
if (query.originId === '' || query.destinationId === ''
|| query.startDate === '' || query.returnDate === ''
|| query.firstName === '' || query.tripType === ''
)
}); | ||
|
||
|
||
export default query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! this file looks nice.
- Add tests - Add verify token validation - Add user is verified validation - Add validate query parameters validation middleware - Add search query parameter query function - Add search controller - Add route API documentation [Finishes #169258648]
fb4014a
to
1988f65
Compare
const searchingTrips = await CommonQueries.findAll( | ||
trips, commonSearchQueries(query, req.user.id) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful nested queries! That's great.
const query = (searchQueryParams, id) => ({ | ||
where: { | ||
...searchQueryParams.startDate && { | ||
startDate: { | ||
[Op.iLike]: `%${searchQueryParams.startDate.trim()}%` | ||
} | ||
}, | ||
...searchQueryParams.returnDate && { | ||
returnDate: { | ||
[Op.iLike]: `%${searchQueryParams.returnDate.trim()}%` | ||
} | ||
}, | ||
...searchQueryParams.originId && { | ||
originId: { | ||
[Op.eq]: parseInt((searchQueryParams.originId), 10) | ||
} | ||
}, | ||
...searchQueryParams.destinationId && { | ||
destinationId: { | ||
[Op.eq]: parseInt((searchQueryParams.destinationId), 10) | ||
} | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the way you come up with this queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job @nziokaivy. I have lost a mistake that you might have done.
What does this PR do?
As a user, I should be able to use the search component so, I can easily retrieve records from both the request and approval table
Description of Task to be completed?
How should this be manually tested?
git clone https://github.com/andela/team-odd-bn-backend.git
git checkout ft-search-functionality-169258648
Any background context you want to provide?
As requests and approval tables grow, it should be easy to find requests through the search functionality
What are the relevant pivotal tracker stories?
#169258648
Screenshots (if appropriate)
Search by originId
Search by destinationId
Search by trip type
Search by status
Search by trip owner(by their first name)
Questions: