PM-4886 Allow multiple countries in member search#84
PM-4886 Allow multiple countries in member search#84himaniraghav3 wants to merge 1 commit intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Enables multi-select country filtering for the Member Search report endpoint (PM-4886), updating the request DTO, service SQL filter construction, and related tests to accept an array of countries instead of a single value.
Changes:
- Replaced single
countryfilter withcountries: string[]in the Member Search DTO and updated Swagger metadata/validation. - Updated member search SQL WHERE clause to match any of the provided countries (case-insensitive) across multiple member country fields.
- Updated controller/service specs and CircleCI branch filters for PM-4886.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/reports/member/member-search.service.ts |
Builds a multi-country SQL filter using a parameterized array and ANY(...) matching. |
src/reports/member/member-search.service.spec.ts |
Updates expectations for the new countries param shape in query params. |
src/reports/member/member-search.controller.spec.ts |
Updates request body to use countries array. |
src/reports/member/dto/member-search.dto.ts |
Changes API contract from country to countries[] and adds array validation + Swagger docs. |
.circleci/config.yml |
Adds PM-4886 branch to dev workflow filter list. |
Comments suppressed due to low confidence (1)
src/reports/member/member-search.service.spec.ts:100
- This test only covers a single country value, but the new behavior is specifically multi-select. Add coverage for multiple countries (e.g.,
['us','ca']) and for normalization behavior (trimming and dropping empty strings) to ensure the SQL/params are built correctly for the multi-country case.
await service.search({
countries: ["us"],
page: 2,
limit: 5,
sortBy: "handle",
sortOrder: "asc",
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @IsOptional() | ||
| @IsString() | ||
| country?: string; | ||
| @IsArray() | ||
| @ArrayNotEmpty() | ||
| @IsString({ each: true }) |
There was a problem hiding this comment.
countries is 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 [] to undefined so empty selections don’t cause 400 responses.
| `( | ||
| LOWER(m."homeCountryCode") = ANY(SELECT LOWER(c) FROM unnest(${pCountries}::text[]) AS c) | ||
| OR LOWER(m."competitionCountryCode") = ANY(SELECT LOWER(c) FROM unnest(${pCountries}::text[]) AS c) | ||
| OR LOWER(m.country) = ANY(SELECT LOWER(c) FROM unnest(${pCountries}::text[]) AS c) | ||
| )`, |
There was a problem hiding this comment.
The country filter repeats unnest(${pCountries}::text[]) and lowercasing three times. You can simplify and likely improve planning/execution by normalizing the input list to lowercase once in TypeScript (and optionally deduping) and then using LOWER(column) = ANY($n::text[]) for each column, avoiding the repeated subselect/unnest.
There was a problem hiding this comment.
@himaniraghav3 This sounds good optimization. you can more than likely pass this comment to AI to apply this refactor.
Allows multi-select country filter on member search
https://topcoder.atlassian.net/browse/PM-4886