Skip to content

Improve member search 2#98

Merged
kkartunov merged 3 commits into
developfrom
improve-member-search-2
May 13, 2026
Merged

Improve member search 2#98
kkartunov merged 3 commits into
developfrom
improve-member-search-2

Conversation

@vas3a
Copy link
Copy Markdown
Collaborator

@vas3a vas3a commented May 13, 2026

This pull request introduces several improvements and fixes to the member search functionality, with a focus on query efficiency, correctness, and maintainability. The main changes include refactoring how event type IDs are loaded and used, ensuring only active members are considered throughout the query, improving country code normalization and filtering, and simplifying the pagination/count logic.

Database query improvements:

  • Refactored to preload winEventTypeIds and engagementSourceTypeId on module initialization using the OnModuleInit lifecycle, reducing repeated database lookups and improving performance.
  • Ensured all skill and event-related queries filter only for active members by introducing an active_members CTE and referencing it throughout, which increases accuracy and efficiency.

Country code and filtering fixes:

  • Standardized country code normalization to uppercase and updated all related SQL filters to use uppercase for consistency and correctness.

SQL join and filter logic adjustments:

  • Replaced dynamic SQL string assembly for skill joins with explicit INNER JOIN statements for better clarity and maintainability.
  • Removed unnecessary LOWER() calls in display mode name checks, as the data is now expected to be case-sensitive and consistent.

Pagination and counting simplification:

  • Simplified the total count logic for pagination by estimating if there are more results based on the page size, instead of running a separate count query, improving performance for large datasets.

@kkartunov kkartunov merged commit bdaa035 into develop May 13, 2026
8 checks passed
@vas3a vas3a deleted the improve-member-search-2 branch May 13, 2026 10:18
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

This PR refactors the member search query to reduce repeated lookups, tighten correctness around “active” members, normalize country filtering, and reduce pagination overhead.

Changes:

  • Preloads skill event type IDs / engagement source type ID on module init and uses IDs instead of name-based joins.
  • Introduces an active_members CTE and reuses it across skill/event/verification activity CTEs.
  • Normalizes country inputs to uppercase and adjusts SQL filters accordingly; replaces exact count query with an estimated “total”.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
src/reports/member/member-search.service.ts Refactors SQL CTEs/joins for active-only filtering, cached IDs for win/engagement detection, country normalization, and replaces COUNT-based pagination total.
.circleci/config.yml Adds the feature branch name to the CircleCI workflow branch allowlist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/reports/member/member-search.service.ts
Comment thread src/reports/member/member-search.service.ts
Comment thread src/reports/member/member-search.service.ts
Comment thread src/reports/member/member-search.service.ts
Comment thread src/reports/member/member-search.service.ts
Comment on lines +397 to 399
LEFT JOIN user_match_data umd ON umd.user_id = m."userId"
LEFT JOIN verified_via_trolley vt ON vt.user_id = m."userId"
LEFT JOIN member_address maddr ON maddr."userId" = m."userId"
Comment thread .circleci/config.yml
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