From 50fe9731051f2684a2af4b43fe509f7470a546a4 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Thu, 27 Nov 2025 11:30:54 -0500 Subject: [PATCH] Remove N+1 on the cards board. --- app/models/card.rb | 2 +- app/models/filter.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/card.rb b/app/models/card.rb index 33a993f71..0a589d0b7 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -22,7 +22,7 @@ class Card < ApplicationRecord scope :chronologically, -> { order created_at: :asc, id: :asc } scope :latest, -> { order last_active_at: :desc, id: :desc } scope :with_users, -> { preload(creator: [ :avatar_attachment, :account ], assignees: [ :avatar_attachment, :account ]) } - scope :preloaded, -> { with_users.preload(:column, :tags, :steps, :closure, :goldness, :activity_spike, :image_attachment, board: [ :entropy ], not_now: [ :user ]).with_rich_text_description_and_embeds } + scope :preloaded, -> { with_users.preload(:column, :tags, :steps, :closure, :goldness, :activity_spike, :image_attachment, board: [ :entropy, :columns ], not_now: [ :user ]).with_rich_text_description_and_embeds } scope :indexed_by, ->(index) do case index diff --git a/app/models/filter.rb b/app/models/filter.rb index 7a398d03d..9dac977bd 100644 --- a/app/models/filter.rb +++ b/app/models/filter.rb @@ -18,7 +18,7 @@ class Filter < ApplicationRecord def cards @cards ||= begin - result = creator.accessible_cards.published + result = creator.accessible_cards.preloaded.published result = result.indexed_by(indexed_by) result = result.sorted_by(sorted_by) result = result.where(id: card_ids) if card_ids.present?