RealDevSquad / RealDevSquad/website-backend
[RFC] filter users based on roles
Open
@anishpawaskar is already working on this.
Since Oct 7, 2023.
backend
- Dominant language
- JavaScript
- Stars
- 74
- Forks
- 276
- Avg merge
- 1d 26m
- Merged PRs (30d)
- 14
Description
Why we are making this change?
- We are planning to deprecate the
/membersAPI because naming convention is not right and it is returning the wrong data it should return members but it’s returning all the users as well as members.
What is change?
- We are planning to use
/usersAPI instead of using/members. - We are planning to add
roleandincludequery in/usersto filter out users based on role. if any user have a rolemember=trueandinclude=truethen it should returns all the users who have role member as true. - We are planning to add one more query
include=trueorinclude=falsebased on this users will filter out.
For ex:- If someone hits this route
/users?role=member&include=truethen it should returns all the users who have role member as true. - If someone hits this route
/users?role=member&include=falsethen it should returns all the users who have role member as false.
- If someone hits this route
Filter users using multiple roles:
- If we try to pass multiple roles in
role querythen the response should be paginated.
For eg:- If someone hits this route
/users?role=member,maven&include=truethen it should return users who have role maven or member as true. - If someone hits this route
/users?role=member,maven&include=falsethen it should return users who have role maven or member as false.
- If someone hits this route
Issue:
- While querying over database if a particular field does not exist in document then it exclude documents where the given field does not exist.
- As of now in our users data the member field is only available in users who are member.
- So if we try to query over users who don't have member field that users will be skipped.
Possible solutions:
- I will make a script which can add member field in users who don't have it. So it makes possible to query over database.
- We can filter out users like how we are doing it on front-end. Like we get all users and then we can check that user have member field or not if not then we will push that users in array then we will return it in response.
Queries:
- ?q=role:member+role:maven+-role:admin
queryParser: https://replit.com/@AimBhai/praksh-query-filter - ?q=roleInclude:member,developer+roleExclude:maven+incompleteUserDetails:true
queryParser: https://replit.com/@AimBhai/vinayak-query-filter#index.js - ?q=role%3Amember+role%3AAmaven+value%3Afalse
queryParser: https://replit.com/@AimBhai/filter-users-based-on-role#index.js
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.