-
Notifications
You must be signed in to change notification settings - Fork 0
PM-4886 Allow multiple countries in member search #84
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ export class MemberSearchService { | |
| openToWork, | ||
| recentlyActive, | ||
| verifiedProfile, | ||
| country, | ||
| countries, | ||
| sortBy = "matchIndex", | ||
| sortOrder = "desc", | ||
| page = 1, | ||
|
|
@@ -201,10 +201,24 @@ member_address AS ( | |
| ); | ||
| } | ||
|
|
||
| if (country) { | ||
| const pCountry = p(country); | ||
| const normalizedCountries = Array.isArray(countries) | ||
| ? [ | ||
| ...new Set( | ||
| countries | ||
| .map((value) => String(value).trim().toLowerCase()) | ||
| .filter(Boolean), | ||
| ), | ||
| ] | ||
| : []; | ||
|
|
||
| if (normalizedCountries.length > 0) { | ||
| const pCountries = p(normalizedCountries); | ||
| where.push( | ||
| `(LOWER(m."homeCountryCode") = LOWER(${pCountry}) OR LOWER(m."competitionCountryCode") = LOWER(${pCountry}) OR LOWER(m.country) = LOWER(${pCountry}))`, | ||
| `( | ||
| LOWER(m."homeCountryCode") = ANY(${pCountries}::text[]) | ||
| OR LOWER(m."competitionCountryCode") = ANY(${pCountries}::text[]) | ||
| OR LOWER(m.country) = ANY(${pCountries}::text[]) | ||
| )`, | ||
|
Comment on lines
+217
to
+221
|
||
| ); | ||
| } | ||
|
|
||
|
|
||
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.
countriesis optional, but@ArrayNotEmpty()will reject requests that send an empty array (common for multi-select UIs where an empty selection is represented as[]). Since the service already treats an empty array as “no filter”, consider removing@ArrayNotEmpty()or transforming[]toundefinedso empty selections don’t cause 400 responses.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.
@himaniraghav3 this one makes sense