Include group names in member search closing #375 #426

Merged
simon merged 3 commits from feature/groups-search-integration into main 2026-02-18 13:28:51 +01:00
Owner

Description of the implemented changes

The changes were:

  • Bugfixing
  • New Feature
  • Breaking Change
  • Refactoring

Include group names in member search (Issue #375). Searching for a group name (e.g. "Vorstand" or "Board Members") in the existing member search now returns all members who belong to a group with that name. No new UI; the existing search box uses an updated search_vector and DB triggers.


What has been changed?

  • Database (new migration 20260217120000_add_group_names_to_member_search_vector.exs):

    • members_search_vector_trigger() now adds the member’s group names (from member_groupsgroups) to search_vector with weight B (same as notes).
    • New trigger on member_groups: update_member_search_vector_on_member_groups_change runs on INSERT/UPDATE/DELETE and refreshes the affected member’s search_vector so it stays in sync when members are added to or removed from groups.
    • update_member_search_vector_from_custom_field_value() updated to include group names when recomputing after custom field changes.
    • One-time backfill of members.search_vector so existing members are searchable by group name. Down migration restores previous trigger logic and backfills without group names.
  • Tests:

    • New: test/membership/member_search_groups_integration_test.exs – search by group name, multiple groups, no false positives, search vector updates on add/remove (INSERT/DELETE on member_groups), partial/special-character cases, and authorization (actor only sees allowed members). One test uses a member name that does not overlap the group name so the “remove from group” case is not matched by trigram on first/last name.
    • Updated: test/mv_web/member_live/index_groups_integration_test.exs – includes the “member index search by group name returns members in that group” scenario (and any related integration tests you added there).
  • Documentation:

    • database-schema-readme.md: Full-Text Search section updated: both triggers described, group names added to weighted fields (weight B), new subsection “Group Names in Search” (trigger name, migration reference).
    • groups-architecture.md: Issue 5 (Search Integration) marked as implemented with migration name and note that fuzzy search is extended via search_vector (no Elixir change).
    • feature-roadmap.md: Under Groups, “Member search includes group names” and #375 listed as closed/implemented.
  • No application/Elixir search code changes: Member.fuzzy_search/2 and the :search action already use search_vector (FTS); group names are included once the triggers and backfill are in place.


Definition of Done

Code Quality

  • No new technical depths
  • Linting passed (Credo clean on migration and new test file; mix format run)
  • Documentation is added where needed (schema readme, groups architecture, feature roadmap)

Accessibility

  • New elements are properly defined with html-tags — N/A (backend/DB only, no new UI)
  • Colour contrast follows WCAG criteria — N/A
  • Aria labels are added when needed — N/A
  • Everything is accessible by keyboard — N/A
  • Tab-Order is comprehensible — N/A
  • All interactive elements have a visible focus — N/A

Testing

  • Tests for new code are written (member search groups integration test + index groups integration test)
  • All tests pass (17 tests in the two groups integration test files)
  • axe-core dev tools show no critical or major issues — N/A (no new UI)

Additional Notes

  • Review focus: Migration SQL (trigger logic, correct use of NEW/OLD on member_groups, backfill and down), and that the new integration tests cover the intended behaviour (search by group name, add/remove membership, authorization).
  • One test adjustment: The “removing member from group updates search vector” test uses a member “Zara None” instead of “Remove Me” so that the query “RemovedGroup” does not match via trigram on first name; the test then correctly asserts that only the search_vector (group names) drives the result after removal.
  • Closes: Issue #375 (Search Integration – group names in member search).
  • Depends on: Groups resource and member_groups table (already on main via #371/#378). No dependency on #374 (member detail groups) for the search behaviour itself.
## Description of the implemented changes The changes were: - [ ] Bugfixing - [x] New Feature - [ ] Breaking Change - [ ] Refactoring **Include group names in member search (Issue #375).** Searching for a group name (e.g. "Vorstand" or "Board Members") in the existing member search now returns all members who belong to a group with that name. No new UI; the existing search box uses an updated `search_vector` and DB triggers. --- ## What has been changed? - **Database (new migration `20260217120000_add_group_names_to_member_search_vector.exs`):** - `members_search_vector_trigger()` now adds the member’s group names (from `member_groups` → `groups`) to `search_vector` with weight B (same as notes). - New trigger on `member_groups`: `update_member_search_vector_on_member_groups_change` runs on INSERT/UPDATE/DELETE and refreshes the affected member’s `search_vector` so it stays in sync when members are added to or removed from groups. - `update_member_search_vector_from_custom_field_value()` updated to include group names when recomputing after custom field changes. - One-time backfill of `members.search_vector` so existing members are searchable by group name. Down migration restores previous trigger logic and backfills without group names. - **Tests:** - **New:** `test/membership/member_search_groups_integration_test.exs` – search by group name, multiple groups, no false positives, search vector updates on add/remove (INSERT/DELETE on `member_groups`), partial/special-character cases, and authorization (actor only sees allowed members). One test uses a member name that does not overlap the group name so the “remove from group” case is not matched by trigram on first/last name. - **Updated:** `test/mv_web/member_live/index_groups_integration_test.exs` – includes the “member index search by group name returns members in that group” scenario (and any related integration tests you added there). - **Documentation:** - **database-schema-readme.md:** Full-Text Search section updated: both triggers described, group names added to weighted fields (weight B), new subsection “Group Names in Search” (trigger name, migration reference). - **groups-architecture.md:** Issue 5 (Search Integration) marked as implemented with migration name and note that fuzzy search is extended via `search_vector` (no Elixir change). - **feature-roadmap.md:** Under Groups, “Member search includes group names” and #375 listed as closed/implemented. - **No application/Elixir search code changes:** `Member.fuzzy_search/2` and the `:search` action already use `search_vector` (FTS); group names are included once the triggers and backfill are in place. --- ## Definition of Done ### Code Quality - [x] No new technical depths - [x] Linting passed (Credo clean on migration and new test file; `mix format` run) - [x] Documentation is added where needed (schema readme, groups architecture, feature roadmap) ### Accessibility - [x] New elements are properly defined with html-tags — N/A (backend/DB only, no new UI) - [x] Colour contrast follows WCAG criteria — N/A - [x] Aria labels are added when needed — N/A - [x] Everything is accessible by keyboard — N/A - [x] Tab-Order is comprehensible — N/A - [x] All interactive elements have a visible focus — N/A ### Testing - [x] Tests for new code are written (member search groups integration test + index groups integration test) - [x] All tests pass (17 tests in the two groups integration test files) - [x] axe-core dev tools show no critical or major issues — N/A (no new UI) --- ## Additional Notes - **Review focus:** Migration SQL (trigger logic, correct use of `NEW`/`OLD` on `member_groups`, backfill and down), and that the new integration tests cover the intended behaviour (search by group name, add/remove membership, authorization). - **One test adjustment:** The “removing member from group updates search vector” test uses a member “Zara None” instead of “Remove Me” so that the query “RemovedGroup” does not match via trigram on first name; the test then correctly asserts that only the `search_vector` (group names) drives the result after removal. - **Closes:** Issue #375 (Search Integration – group names in member search). - **Depends on:** Groups resource and `member_groups` table (already on main via #371/#378). No dependency on #374 (member detail groups) for the search behaviour itself.
simon added 1 commit 2026-02-18 12:48:49 +01:00
feat: add groups to search vector
Some checks reported errors
continuous-integration/drone/push Build was killed
f6575319f7
Co-authored-by: Cursor <cursoragent@cursor.com>
simon added 1 commit 2026-02-18 13:06:06 +01:00
fix: adress review comments
Some checks failed
continuous-integration/drone/push Build is failing
63b8e70e62
simon added 1 commit 2026-02-18 13:06:33 +01:00
Merge branch 'main' into feature/groups-search-integration
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/promote/production Build is failing
84f97c12f8
simon merged commit adea380d86 into main 2026-02-18 13:28:51 +01:00
simon deleted branch feature/groups-search-integration 2026-02-18 13:28:52 +01:00
Sign in to join this conversation.
No description provided.