Skip to content

refactor(activists): organizer columns and fill in undefined booleans#346

Merged
alexsapps merged 2 commits intomainfrom
alex/column-refactor
Mar 20, 2026
Merged

refactor(activists): organizer columns and fill in undefined booleans#346
alexsapps merged 2 commits intomainfrom
alex/column-refactor

Conversation

@alexsapps
Copy link
Copy Markdown
Collaborator

@alexsapps alexsapps commented Mar 20, 2026

Summary by CodeRabbit

  • Refactor
    • More reliable column lookups and consistent column ordering/grouping for the activists view.
  • Bug Fixes
    • Blank values now display as 0 for numeric fields and false for boolean fields across lists and detail views.
  • New Features
    • Added a hidden Chapter ID column and more predictable column-selection behavior when filters change.

@alexsapps alexsapps requested a review from jakehobbs as a code owner March 20, 2026 00:26
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 20, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Replace array-based column lookups with a name→definition map, move column-selection logic into a new module, add blankValue metadata and blank-field lists, and update API/result handling to fill numeric and boolean blank fields in-place.

Changes

Cohort / File(s) Summary
Column definitions & utilities
frontend-v2/src/app/(authed)/activists/column-definitions.ts, frontend-v2/src/app/(authed)/activists/column-selection.ts
Add optional blankValue to ColumnDefinition; export COLUMN_DEFINITION_BY_NAME, BLANK_TO_ZERO_FIELDS, BLANK_TO_FALSE_FIELDS, COLUMN_ORDER_BY_NAME, GROUPED_COLUMNS_BY_CATEGORY, and isActivistColumnName. Extract normalizeColumns, columnsForNewFilters, normalizeColumnsForFilters into a new column-selection.ts.
Table & UI consumers
frontend-v2/src/app/(authed)/activists/activists-table.tsx, frontend-v2/src/app/(authed)/activists/activists-table.test.tsx, frontend-v2/src/app/(authed)/activists/sort-selector.tsx, frontend-v2/src/app/(authed)/activists/format-value.ts
Replace .find(...) lookups on COLUMN_DEFINITIONS with direct COLUMN_DEFINITION_BY_NAME[...] indexing for label/size/minWidth/isDate; update tests to use the new lookup.
Import / grouping / parsers
frontend-v2/src/app/(authed)/activists/column-selector.tsx, frontend-v2/src/app/(authed)/activists/search-params.ts, frontend-v2/src/app/(authed)/activists/filter-api-query.ts, frontend-v2/src/app/(authed)/activists/use-activist-query-state.ts
Switch to GROUPED_COLUMNS_BY_CATEGORY; move normalization functions to column-selection.ts; use isActivistColumnName for runtime column validation in parsers.
API blank-field handling
frontend-v2/src/lib/api.ts
Refactor to parse responses and mutate activists in-place, replacing numeric-only blank normalization with fillActivistBlankFields that applies both BLANK_TO_ZERO_FIELDS and BLANK_TO_FALSE_FIELDS.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Activists UI
    participant ColDefs as ColumnDefinitions (map)
    participant Query as Query Builder
    participant API as ApiClient
    participant Processor as Response Processor

    UI->>ColDefs: Read COLUMN_DEFINITION_BY_NAME, GROUPED_COLUMNS_BY_CATEGORY
    UI->>Query: Build query (normalizeColumnsForFilters, columnsForNewFilters)
    Query->>API: searchActivists(request)
    API->>Processor: parse JSON -> fillActivistBlankFields using BLANK_TO_ZERO_FIELDS / BLANK_TO_FALSE_FIELDS
    Processor->>UI: return QueryActivistResult with mutated activists
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • jakehobbs

Poem

🐰 I hopped through columns, neat and spry,
I mapped each name instead of scanning by.
Zeros and falses snug and small,
Columns grouped and ordered, one and all.
A tiny rabbit's tidy cheer! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title references 'organizer columns' but the PR primarily refactors column metadata lookup and reorganizes column selection logic; 'fill in undefined booleans' is a secondary concern addressed via new blank field infrastructure. Consider whether 'organizer columns' accurately describes the main refactoring work, or clarify the title to emphasize the column metadata/lookup refactoring and blank field handling consolidation.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alex/column-refactor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@alexsapps alexsapps changed the title fix(activists): fill in undefined boolean values refactor(activists): organizer columns and fill in undefined booleans Mar 20, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend-v2/src/app/`(authed)/activists/column-definitions.ts:
- Around line 457-466: The grouping uses spread on each iteration causing
unnecessary allocations; update the GROUPED_COLUMNS_BY_CATEGORY IIFE to retrieve
the array for a category from the Map (GROUPED_COLUMNS_BY_CATEGORY) or create
and set a new array when missing, then call .push(column) on that array instead
of setting a new array via [...existing, column]; keep the Map type and final
return intact and reference COLUMN_DEFINITIONS and column.category/column to
locate the loop to modify.

In `@frontend-v2/src/app/`(authed)/activists/column-selection.ts:
- Around line 5-20: The comment above FILTER_COLUMN_MAP is missing mention of
the prospect filter; either add prospect to the excluded list in the comment (if
there is no single corresponding column) or add a mapping entry in
FILTER_COLUMN_MAP for prospect (using the correct ActivistColumnName value from
ActivistColumnName / FilterState) so the code and comment stay consistent—update
the comment text or add the prospect: 'prospect' mapping in the
FILTER_COLUMN_MAP accordingly.

In `@frontend-v2/src/lib/api.ts`:
- Line 605: The function fillActivistBlankNumericFieldsWithZero now normalizes
both numeric and boolean blanks, so rename it to a clearer name (e.g.,
normalizeActivistBlankFields or fillActivistBlankFields) and update all
references: rename the function declaration and any exports, imports, and
callers that reference fillActivistBlankNumericFieldsWithZero (search for that
symbol across the repo), and update JSDoc/type annotations and tests to reflect
the new name and intent; ensure you run typechecks and adjust any public API
docs where the old name appears.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8ce2e465-1241-4563-8d1a-ee4f4e5c6da7

📥 Commits

Reviewing files that changed from the base of the PR and between 36693ed and a8ba584.

📒 Files selected for processing (11)
  • frontend-v2/src/app/(authed)/activists/activists-table.test.tsx
  • frontend-v2/src/app/(authed)/activists/activists-table.tsx
  • frontend-v2/src/app/(authed)/activists/column-definitions.ts
  • frontend-v2/src/app/(authed)/activists/column-selection.ts
  • frontend-v2/src/app/(authed)/activists/column-selector.tsx
  • frontend-v2/src/app/(authed)/activists/filter-api-query.ts
  • frontend-v2/src/app/(authed)/activists/format-value.ts
  • frontend-v2/src/app/(authed)/activists/search-params.ts
  • frontend-v2/src/app/(authed)/activists/sort-selector.tsx
  • frontend-v2/src/app/(authed)/activists/use-activist-query-state.ts
  • frontend-v2/src/lib/api.ts

Comment thread frontend-v2/src/app/(authed)/activists/column-definitions.ts
Comment thread frontend-v2/src/app/(authed)/activists/column-selection.ts
Comment thread frontend-v2/src/lib/api.ts Outdated
@alexsapps alexsapps force-pushed the alex/column-refactor branch from a8ba584 to c9c41f5 Compare March 20, 2026 19:48
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend-v2/src/app/`(authed)/activists/column-definitions.ts:
- Around line 441-443: COLUMN_DEFINITION_BY_NAME is being asserted as
Record<ActivistColumnName, ColumnDefinition> but ActivistColumnName (derived
from Object.keys(ActivistJSON.shape)) includes "chapter_id" which is not present
in COLUMN_DEFINITIONS, so the assertion is lying; fix by either adding a
ColumnDefinition for "chapter_id" to COLUMN_DEFINITIONS (with appropriate
display/formatter/width) or remove "chapter_id" from the ActivistJSON.shape (or
from the ActivistColumnName union) if it should not be a visible column; update
the code where COLUMN_DEFINITIONS and ActivistJSON.shape are defined to keep
them in sync so COLUMN_DEFINITION_BY_NAME genuinely contains every
ActivistColumnName.

In `@frontend-v2/src/lib/api.ts`:
- Around line 8-11: Move the BLANK_TO_ZERO_FIELDS and BLANK_TO_FALSE_FIELDS
constants out of the application layer and into the API layer by adding them to
the API activists module where ActivistJSON is defined (e.g.,
`@/lib/api/activists.ts`), then update imports in frontend-v2/src/lib/api.ts to
import those constants from the new API module instead of from
`@/app/`(authed)/activists/column-definitions; ensure the constants are exported
from the activists API module and used by any code that normalizes ActivistJSON
objects so you preserve behavior while eliminating the lib -> app dependency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 680bc0e9-6f09-4829-bcbc-c3abb2c572e5

📥 Commits

Reviewing files that changed from the base of the PR and between a8ba584 and c9c41f5.

📒 Files selected for processing (3)
  • frontend-v2/src/app/(authed)/activists/column-definitions.ts
  • frontend-v2/src/app/(authed)/activists/column-selection.ts
  • frontend-v2/src/lib/api.ts

Comment thread frontend-v2/src/app/(authed)/activists/column-definitions.ts
Comment thread frontend-v2/src/lib/api.ts
@alexsapps alexsapps force-pushed the alex/column-refactor branch from c9c41f5 to cab30d9 Compare March 20, 2026 20:35
@alexsapps alexsapps merged commit ecc4acc into main Mar 20, 2026
1 of 2 checks passed
@alexsapps alexsapps deleted the alex/column-refactor branch March 20, 2026 20:37
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.

1 participant