RealDevSquad / RealDevSquad/website-backend
Users search not working correctly
@manish591 is already working on this.
Since Aug 5, 2023.
- Dominant language
- JavaScript
- Stars
- 74
- Forks
- 276
- Avg merge
- 1d 26m
- Merged PRs (30d)
- 14
Description
Issue
When assigning a task to some user in the status site, the /users?search=<username> API cannot call some of the user names.
Problem
Suppose the current user model looks like this:
{
first_name: "manish",
username: "Manish",
// Other details
},
{
first_name: "ritika",
username: "ritika",
// Other details
},
And we pass query=Ma
The expected result should be the user with a username containing Ma.
But, It is returning an empty array like this because firebase filtering and sorting are case sensitive.
{
"message": "Users Returned Successfully",
"users": [],
// Other details
}
This is happening because when we are filtering users based on a query we are changing the query to lowercase.
dbQuery = dbQuery
.startAt(query.search.toLowerCase().trim())
.endAt(query.search.toLowerCase().trim() + "\uf8ff");
What this does is if query=Ma. It will first change it to ma and then filter users based on the query ma. And suppose if in the user model, the username is written in uppercase like Manish, It won't match this case. Because ma doesn't; exits in username Manish.
Solution
Solution 1
Another solution is to get all the users and, then create a function that will loop through all the users and returns the users whose username matches the query.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.