Skip to content

PM-4886 Allow multiple countries in member search#84

Open
himaniraghav3 wants to merge 1 commit intodevelopfrom
PM-4886
Open

PM-4886 Allow multiple countries in member search#84
himaniraghav3 wants to merge 1 commit intodevelopfrom
PM-4886

Conversation

@himaniraghav3
Copy link
Copy Markdown
Collaborator

Allows multi-select country filter on member search

https://topcoder.atlassian.net/browse/PM-4886

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 country filter with countries: 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.

Comment thread src/reports/member/dto/member-search.dto.ts
Comment on lines 85 to +88
@IsOptional()
@IsString()
country?: string;
@IsArray()
@ArrayNotEmpty()
@IsString({ each: true })
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

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

Comment on lines +211 to +215
`(
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)
)`,
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@himaniraghav3 This sounds good optimization. you can more than likely pass this comment to AI to apply this refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants