-
Notifications
You must be signed in to change notification settings - Fork 448
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
feat: add feature to the List Users API to filter users by skill #1097
base: develop
Are you sure you want to change the base?
Conversation
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.
@battuAshita the lint check is failing, please run black locally and push the changes
Unless lint passes the build action won't be triggered
@battuAshita one last file and it will pass |
Codecov Report
@@ Coverage Diff @@
## develop #1097 +/- ##
========================================
Coverage 94.94% 94.95%
========================================
Files 38 38
Lines 2058 2061 +3
========================================
+ Hits 1954 1957 +3
Misses 104 104
|
) | ||
if skill != "": | ||
users_list_query = users_list_query.filter( | ||
func.lower(UserModel.skills) == func.lower(skill) |
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.
This will only work when the skill exactly matches. Enable FTS and use proter tokenizer (or the postgres equivalent).
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.
Will make the necessary changes and get back :)
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 @epicadk Please correct me if I'm wrong. Adding FTS would require changes to made in the underlying table right? We need to have a ts_vector column which helps us compare with the given query.
Also, I have a row with skill as "critical thinking"
select * from users where to_tsvector('english', skills) @@ to_tsquery('Criti');
This query did not give me the result whereas
select * from users where skills ilike '%criti%';
This query gave me the result
I feel using something like "ILIKE" would be sufficient here.
Thoughts?
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.
Like with a wildcard at the beginning will not use indexes.
Also porter will match Frustrate to Frustration which would be nice to have since skills isn't an enum.
A good practice is to use Explain Analyze on SQL queries. ( Only for your understanding not in production of course.)
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 @battuAshita please make necessary changes requested below 👇
I have made changes to the code such that we will be able to filter based on the skill even when they are not exactly matched. Like if we search for "Creative", we will be able to get the users with skill "Creativity". Please review this change :) |
Done :) |
There are some conflicts @battuAshita . |
Okay, sure. Will get back :) |
Done. |
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.
Will test it soon
Some minor changes here 👇
Made the necessary changes. Please review them. |
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.
This looks good, I just wonder about the "None" keyword added to the documentation.
Other than that, once that is addressed I am happy to approve :)
Thank you for contributing @battuAshita 🤗
self.need_mentoring = need_mentoring | ||
self.available_to_mentor = available_to_mentor |
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 so this was just making these values set to false 😱 nice catch!
Done :) |
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 work! Thank you for addressing my comments @battuAshita 🙌🏾
Description
Added a new feature to filter both users and verified users based on their skill.
The 'app/api/dao/user.py' and the 'app/api/resources/user.py' files have been updated.
Fixes #759
Type of Change:
Code/Quality Assurance Only
How Has This Been Tested?
I have included a test_dao_filter_by_skill.py file to 'tests/users'.
Both the test cases that I have written have been passed successfully.
Checklist:
Code/Quality Assurance Only