Split member_live/index.ex into a coordinator + modules #535

Open
opened 2026-06-15 22:15:39 +02:00 by moritz · 0 comments
Owner

Motivation

lib/mv_web/live/member_live/index.ex is the worst hotspot on every metric (2028 LOC, ~30 outgoing deps, 23
harvest findings). It mixes query building, residual in-memory filtering/sorting, export-payload building, and
field-visibility/column logic in one LiveView. This is a cohesion split — most filtering/sorting is already in
Ash.Query; only SQL-hard cases stay in-memory. No behavior change.

Scope (ordered steps, CI green each)

  • Step 1: test scaffolding pinning current list/filter/sort/export behavior at the LiveView boundary.
  • Step 2: extract the Ash query builder (filter construction ~L1109-1213, sort ~L1250-1272).
  • Step 3: extract the residual in-memory filter/sort (apply_in_memory_filters, sort_members_in_memory).
  • Step 4: extract the export/email-payload (~L1780-1853) and the field-visibility/column logic (~L1896-2001).
    index.ex becomes a thin LiveView coordinator.

Out of scope

Server-side pagination (R-011) is a product feature, not refactoring, and partly infeasible with the computed
membership_fee_status field — see ISSUES.md Discussion E. Do not add paging here.

Acceptance criteria

  • Behavior parity on the member-list screen (the Step-1 tests stay green throughout).
  • index.ex materially thinner; extracted modules unit-tested.
  • just ci-dev green after each step.

Dependencies

After issue "Mechanical cleanup …" (R-005 logger removal) and "Correctness …" (R-006 atom fix), so those small
edits do not get buried in this large diff.

## Motivation `lib/mv_web/live/member_live/index.ex` is the worst hotspot on every metric (2028 LOC, ~30 outgoing deps, 23 harvest findings). It mixes query building, residual in-memory filtering/sorting, export-payload building, and field-visibility/column logic in one LiveView. This is a cohesion split — most filtering/sorting is already in `Ash.Query`; only SQL-hard cases stay in-memory. **No behavior change.** ## Scope (ordered steps, CI green each) - Step 1: test scaffolding pinning current list/filter/sort/export behavior at the LiveView boundary. - Step 2: extract the Ash query builder (filter construction ~L1109-1213, sort ~L1250-1272). - Step 3: extract the residual in-memory filter/sort (`apply_in_memory_filters`, `sort_members_in_memory`). - Step 4: extract the export/email-payload (~L1780-1853) and the field-visibility/column logic (~L1896-2001). `index.ex` becomes a thin LiveView coordinator. ## Out of scope Server-side pagination (R-011) is a product feature, not refactoring, and partly infeasible with the computed `membership_fee_status` field — see ISSUES.md Discussion E. Do not add paging here. ## Acceptance criteria - Behavior parity on the member-list screen (the Step-1 tests stay green throughout). - `index.ex` materially thinner; extracted modules unit-tested. - `just ci-dev` green after each step. ## Dependencies After issue "Mechanical cleanup …" (R-005 logger removal) and "Correctness …" (R-006 atom fix), so those small edits do not get buried in this large diff.
moritz added this to the Code and Test Refactoring | TI I milestone 2026-06-15 22:15:39 +02:00
moritz added this to the Sprint 18: Juli 2026 project 2026-06-15 22:15:39 +02:00
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: local-it/mitgliederverwaltung#535
No description provided.