PM-5073 - Allow search by preferred roles, remove restriction about skills#105
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the member search API to support filtering members by their open-to-work preferred roles, and adjusts query ordering/performance when searching without skills.
Changes:
- Adds
preferredRoles?: string[]toMemberSearchBodyDtofor API-level filtering. - Updates
MemberSearchServiceSQL generation to filter onopenToWork.preferredRoles(JSONB) with case-insensitive matching. - Changes ordering to prioritize recently active and available-for-gigs members when searching by preferred roles without skills, and avoids joining
user_match_dataunless skills are provided.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/reports/member/member-search.service.ts |
Normalizes preferredRoles, adds JSONB preferred-role filtering, adjusts ORDER BY behavior, and makes user_match_data join conditional. |
src/reports/member/dto/member-search.dto.ts |
Adds preferredRoles to the request DTO with Swagger + validation decorators. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+229
to
+235
| const normalizedPreferredRoles = Array.isArray(preferredRoles) | ||
| ? [ | ||
| ...new Set( | ||
| preferredRoles.map((value) => String(value).trim()).filter(Boolean), | ||
| ), | ||
| ] | ||
| : []; |
Comment on lines
+248
to
+252
| if (normalizedPreferredRoles.length > 0) { | ||
| const pPreferredRoles = p( | ||
| normalizedPreferredRoles.map((value) => value.toUpperCase()), | ||
| ); | ||
| where.push( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances the member search functionality by adding support for filtering and sorting members based on their preferred roles, as specified in their open-to-work personalization trait. The changes include updates to the API DTO, query normalization, SQL filtering, and ordering logic to ensure accurate and relevant search results.
Preferred Roles Filtering and Sorting:
preferredRolesarray property to theMemberSearchBodyDtoto allow filtering members by their preferred roles from the open-to-work personalization trait.MemberSearchServiceto accept thepreferredRolesparameter and normalize its values for consistent processing. [1] [2]Ordering Improvements:
preferredRolesfiltering is applied and no skills are specified; otherwise, default ordering by match index and handle is used.LEFT JOINlogic to only joinuser_match_datawhen skill filters are present, optimizing query performance.