From d72de035450513481e5a42dda0d4f16f49c8fccf Mon Sep 17 00:00:00 2001 From: Alessio Cappa Date: Sun, 24 May 2026 21:05:01 +0200 Subject: [PATCH 1/3] feat: Add pagination in merchants page --- app/controllers/family_merchants_controller.rb | 11 +++++++---- app/views/family_merchants/index.html.erb | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/controllers/family_merchants_controller.rb b/app/controllers/family_merchants_controller.rb index db77ee413e..852abb77d6 100644 --- a/app/controllers/family_merchants_controller.rb +++ b/app/controllers/family_merchants_controller.rb @@ -5,8 +5,8 @@ def index @breadcrumbs = [ [ t("breadcrumbs.home"), root_path ], [ t("breadcrumbs.merchants"), nil ] ] # Show all merchants for this family - @family_merchants = Current.family.merchants.alphabetically - @provider_merchants = Current.family.assigned_merchants_for(Current.user).where(type: "ProviderMerchant").alphabetically + @all_family_merchants = Current.family.merchants.alphabetically + @all_provider_merchants = Current.family.assigned_merchants_for(Current.user).where(type: "ProviderMerchant").alphabetically # Show recently unlinked ProviderMerchants (within last 30 days) # Exclude merchants that are already assigned to transactions (they appear in provider_merchants) @@ -14,12 +14,15 @@ def index .where(family: Current.family) .recently_unlinked .pluck(:merchant_id) - assigned_ids = @provider_merchants.pluck(:id) + assigned_ids = @all_provider_merchants.pluck(:id) @unlinked_merchants = ProviderMerchant.where(id: recently_unlinked_ids - assigned_ids).alphabetically - @enhanceable_count = @provider_merchants.where(website_url: [ nil, "" ]).count + @enhanceable_count = @all_provider_merchants.where(website_url: [ nil, "" ]).count @llm_available = Provider::Registry.get_provider(:openai).present? + @pagy_family_merchants, @family_merchants = pagy(@all_family_merchants, limit: safe_per_page) + @pagy_provider_merchants, @provider_merchants = pagy(@all_provider_merchants, limit: safe_per_page) + render layout: "settings" end diff --git a/app/views/family_merchants/index.html.erb b/app/views/family_merchants/index.html.erb index e647e5833b..090a291aaa 100644 --- a/app/views/family_merchants/index.html.erb +++ b/app/views/family_merchants/index.html.erb @@ -19,10 +19,10 @@

<%= t(".family_title", moniker: family_moniker) %>

· -

<%= @family_merchants.count %>

+

<%= @all_family_merchants.count %>

- <% if @family_merchants.any? %> + <% if @pagy_family_merchants.count > 0 || @family_merchants.any? %>
@@ -52,13 +52,17 @@ <% end %> + +
+ <%= render "shared/pagination", pagy: @pagy_family_merchants %> +

<%= t(".provider_title") %>

· -

<%= @provider_merchants.count %>

+

<%= @all_provider_merchants.count %>

@@ -84,7 +88,7 @@
<% end %> - <% if @provider_merchants.any? %> + <% if @pagy_provider_merchants.count > 0 || @provider_merchants.any? %>
@@ -106,6 +110,10 @@

<%= t(".provider_empty", moniker: family_moniker_downcase) %>

<% end %> + +
+ <%= render "shared/pagination", pagy: @pagy_provider_merchants %> +
<% if @unlinked_merchants.any? %> From c102e68ee0458a342e5753b625fea6b45d36607f Mon Sep 17 00:00:00 2001 From: Alessio Cappa Date: Sun, 24 May 2026 21:16:28 +0200 Subject: [PATCH 2/3] fix: Add separate paginations for family/provider merchants --- app/controllers/family_merchants_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/family_merchants_controller.rb b/app/controllers/family_merchants_controller.rb index 852abb77d6..d6420b01f3 100644 --- a/app/controllers/family_merchants_controller.rb +++ b/app/controllers/family_merchants_controller.rb @@ -20,8 +20,8 @@ def index @enhanceable_count = @all_provider_merchants.where(website_url: [ nil, "" ]).count @llm_available = Provider::Registry.get_provider(:openai).present? - @pagy_family_merchants, @family_merchants = pagy(@all_family_merchants, limit: safe_per_page) - @pagy_provider_merchants, @provider_merchants = pagy(@all_provider_merchants, limit: safe_per_page) + @pagy_family_merchants, @family_merchants = pagy(@all_family_merchants, page_param: :family_page, limit: safe_per_page) + @pagy_provider_merchants, @provider_merchants = pagy(@all_provider_merchants, page_param: :provider_page, limit: safe_per_page) render layout: "settings" end From 2a8173a9da147bdb294835a58b40649faaf95450 Mon Sep 17 00:00:00 2001 From: Alessio Cappa Date: Mon, 25 May 2026 16:28:00 +0200 Subject: [PATCH 3/3] refactor: simplify conditions in view --- app/views/family_merchants/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/family_merchants/index.html.erb b/app/views/family_merchants/index.html.erb index 090a291aaa..ceb8cb07cf 100644 --- a/app/views/family_merchants/index.html.erb +++ b/app/views/family_merchants/index.html.erb @@ -22,7 +22,7 @@

<%= @all_family_merchants.count %>

- <% if @pagy_family_merchants.count > 0 || @family_merchants.any? %> + <% if @all_family_merchants.any? %>
@@ -88,7 +88,7 @@ <% end %> - <% if @pagy_provider_merchants.count > 0 || @provider_merchants.any? %> + <% if @all_provider_merchants.any? %>