feat: add feature to the List Users API to filter users by skill#1097
feat: add feature to the List Users API to filter users by skill#1097battuAshita wants to merge 18 commits intoanitab-org:developfrom
Conversation
vj-codes
left a comment
There was a problem hiding this comment.
@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.
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.
Will make the necessary changes and get back :)
There was a problem hiding this comment.
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.
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.)
devkapilbansal
left a comment
There was a problem hiding this comment.
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. |
devkapilbansal
left a comment
There was a problem hiding this comment.
Will test it soon
Some minor changes here 👇
|
Made the necessary changes. Please review them. |
isabelcosta
left a comment
There was a problem hiding this comment.
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.
wow so this was just making these values set to false 😱 nice catch!
|
Done :) |
isabelcosta
left a comment
There was a problem hiding this comment.
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