Preload cards

This commit is contained in:
Stanko K.R.
2025-11-17 11:50:03 +01:00
committed by Mike Dalessio
parent ee85c25672
commit e539754e2c
3 changed files with 5 additions and 2 deletions
+2 -1
View File
@@ -64,7 +64,8 @@ class BoardsController < ApplicationController
end
def show_columns
set_page_and_extract_portion_from @board.cards.awaiting_triage.latest.with_golden_first
cards = @board.cards.awaiting_triage.latest.with_golden_first.preloaded
set_page_and_extract_portion_from cards
fresh_when etag: [ @board, @page.records, @user_filtering ]
end
+2
View File
@@ -19,6 +19,8 @@ class Card < ApplicationRecord
scope :reverse_chronologically, -> { order created_at: :desc, id: :desc }
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(:board, :column, :tags, :steps, :closure, :not_now, :goldness, :activity_spike) }
scope :indexed_by, ->(index) do
case index
+1 -1
View File
@@ -5,7 +5,7 @@ module Card::Golden
has_one :goldness, dependent: :destroy, class_name: "Card::Goldness"
scope :golden, -> { joins(:goldness) }
scope :with_golden_first, -> { left_outer_joins(:goldness).prepend_order("card_goldnesses.id IS NULL") }
scope :with_golden_first, -> { left_outer_joins(:goldness).prepend_order("card_goldnesses.id IS NULL").preload(:goldness) }
end
def golden?