Skip to content

CRM 0.2.1: A broken custom field no longer crashes the user tables

CRM 0.2.1 fixes a crash in the CRM’s user tables. A custom user field defined without a key made the role and Organizations pages fail to open. Such fields are now left out of the column list, and the pages load.

The release also makes the CRM faster:

  • The CRM overview reads its role statistics once per visit instead of twice, and counts the users of all enabled roles in one query instead of one per role.
  • The user tables look up each column’s settings once per page render instead of once per cell.

Update the dependency; there is no migration and no configuration.

Full release notes: CRM 0.2.1

0.2.1 · 5 May 2026

Bug fixes and performance hardening from the PR #4 retrospective review: LiveView lifecycle correctness on the CRM landing page, an N+1 query collapse, and a per-cell render hot-path optimization. No breaking changes — patch release.

Fixed

  • CRMLive lifecycle. Role-stat loading moved out of mount/3 (which fires twice per connect — HTTP + WebSocket) into handle_params/3 gated on connected?/1. Eliminates duplicate queries on every CRM landing-page render.
  • N+1 across enabled roles. New PhoenixKitCRM.RoleSettings.list_enabled_with_user_counts/0 issues a single GROUP BY with a left join over RoleAssignment, replacing one Roles.count_users_with_role/1 round-trip per role. Roles with zero users still surface (count = 0) thanks to the left join.
  • Per-cell available_columns/1 recomputation. Custom-cell render no longer rebuilds the full [{id, meta}] list per cell. Views compute ColumnConfig.column_metadata_map/1 once per render and pass the resolved map through render_cell/3, card_field/3, column_label/2, and CellFormat.render_custom_cell/3. ColumnModal does the same lookup once at the top of the function component.
  • Unguarded field["key"] in custom-field columns. Malformed custom field definitions (no "key") no longer crash the page with ArgumentError: argument for <> is not a binary — they’re filtered upstream of the Enum.map.
  • Gettext call-style consistency in CRMLive. Switched long-form Gettext.gettext/dngettext(PhoenixKitWeb.Gettext, …) to the short gettext/ngettext already in scope via use PhoenixKitWeb, :live_view, matching RoleView / OrganizationsView.

Added

  • PhoenixKitCRM.ColumnConfig.column_metadata_map/1 — flat %{column_id => meta} map for callers that need lookup-by-id without rebuilding the available-columns list per call.
  • PhoenixKitCRM.RoleSettings.list_enabled_with_user_counts/0 — single GROUP BY query for the CRM overview.

Changed

  • PhoenixKitCRM.Web.CellFormat.render_custom_cell/3 second arg is now a column_meta map (not a scope). Internal callers within CRM are updated; CellFormat was introduced in 0.2.0’s PR #4 follow-ups and has not been released until now, so no upgraders are affected.
  • Dependencies refreshed via mix deps.update --all: bandit, ecto, jason, leaf, phoenix, phoenix_kit, phoenix_live_view, postgrex. Patch / minor only — no constraint changes in mix.exs.

CRM 0.2.1. Install or update: {:phoenix_kit_crm, "~> 0.2"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.