Preload cards for columns
This commit is contained in:
@@ -54,12 +54,13 @@ gem "autotuner"
|
||||
gem "benchmark" # indirect dependency, being removed from Ruby 3.5 stdlib so here to quash warnings
|
||||
|
||||
group :development, :test do
|
||||
gem "debug"
|
||||
gem "bundler-audit", require: false
|
||||
gem "brakeman", require: false
|
||||
gem "rubocop-rails-omakase", require: false
|
||||
gem "letter_opener"
|
||||
gem "bundler-audit", require: false
|
||||
gem "debug"
|
||||
gem "faker"
|
||||
gem "letter_opener"
|
||||
gem "rack-mini-profiler"
|
||||
gem "rubocop-rails-omakase", require: false
|
||||
end
|
||||
|
||||
group :development do
|
||||
|
||||
@@ -384,6 +384,8 @@ GEM
|
||||
raabro (1.4.0)
|
||||
racc (1.8.1)
|
||||
rack (3.2.4)
|
||||
rack-mini-profiler (4.0.1)
|
||||
rack (>= 1.2.0)
|
||||
rack-session (2.1.1)
|
||||
base64 (>= 0.1.0)
|
||||
rack (>= 3.0.0)
|
||||
@@ -606,6 +608,7 @@ DEPENDENCIES
|
||||
propshaft
|
||||
puma (>= 5.0)
|
||||
queenbee!
|
||||
rack-mini-profiler
|
||||
rails!
|
||||
rails_structured_logging!
|
||||
redcarpet
|
||||
|
||||
@@ -2,7 +2,7 @@ class Boards::Columns::ClosedsController < ApplicationController
|
||||
include BoardScoped
|
||||
|
||||
def show
|
||||
set_page_and_extract_portion_from @board.cards.closed.recently_closed_first
|
||||
set_page_and_extract_portion_from @board.cards.closed.recently_closed_first.preloaded
|
||||
fresh_when etag: @page.records
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Boards::Columns::NotNowsController < ApplicationController
|
||||
include BoardScoped
|
||||
|
||||
def show
|
||||
set_page_and_extract_portion_from @board.cards.postponed.reverse_chronologically.with_golden_first
|
||||
set_page_and_extract_portion_from @board.cards.postponed.reverse_chronologically.with_golden_first.preloaded
|
||||
fresh_when etag: @page.records
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Boards::Columns::StreamsController < ApplicationController
|
||||
include BoardScoped
|
||||
|
||||
def show
|
||||
set_page_and_extract_portion_from @board.cards.awaiting_triage.latest.with_golden_first
|
||||
set_page_and_extract_portion_from @board.cards.awaiting_triage.latest.with_golden_first.preloaded
|
||||
fresh_when etag: @page.records
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Boards::ColumnsController < ApplicationController
|
||||
before_action :set_column, only: %i[ show update destroy ]
|
||||
|
||||
def show
|
||||
set_page_and_extract_portion_from @column.cards.active.latest.with_golden_first
|
||||
set_page_and_extract_portion_from @column.cards.active.latest.with_golden_first.preloaded
|
||||
fresh_when etag: @page.records
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class NotificationsController < ApplicationController
|
||||
def index
|
||||
@unread = Current.user.notifications.unread.ordered unless current_page_param
|
||||
set_page_and_extract_portion_from Current.user.notifications.read.ordered
|
||||
@unread = Current.user.notifications.unread.ordered.preloaded unless current_page_param
|
||||
set_page_and_extract_portion_from Current.user.notifications.read.ordered.preloaded
|
||||
|
||||
respond_to do |format|
|
||||
format.turbo_stream if current_page_param # Allows read-all action to side step pagination
|
||||
|
||||
@@ -27,7 +27,7 @@ module AccessesHelper
|
||||
end
|
||||
|
||||
def board_watchers_list(board)
|
||||
watchers = board.watchers
|
||||
watchers = board.watchers.with_avatars
|
||||
|
||||
displayed_watchers = watchers.limit(MAX_DISPLAYED_WATCHERS)
|
||||
overflow_count = watchers.count - MAX_DISPLAYED_WATCHERS
|
||||
|
||||
+2
-2
@@ -19,8 +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 :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 :indexed_by, ->(index) do
|
||||
case index
|
||||
|
||||
@@ -18,7 +18,7 @@ module Filter::Resources
|
||||
end
|
||||
|
||||
def boards
|
||||
creator.boards.where id: super.ids
|
||||
@boards ||= creator.boards.where id: super.ids
|
||||
end
|
||||
|
||||
def board_titles
|
||||
|
||||
@@ -14,6 +14,8 @@ class Notification < ApplicationRecord
|
||||
after_destroy_commit :broadcast_read
|
||||
after_create :bundle
|
||||
|
||||
scope :preloaded, -> { preload(:creator, :account, source: [ :board, :creator ]) }
|
||||
|
||||
delegate :notifiable_target, to: :source
|
||||
delegate :card, to: :source
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ class User < ApplicationRecord
|
||||
has_many :pins, dependent: :destroy
|
||||
has_many :pinned_cards, through: :pins, source: :card
|
||||
|
||||
scope :with_avatars, -> { preload(:account, :avatar_attachment) }
|
||||
|
||||
delegate :staff?, to: :identity, allow_nil: true
|
||||
|
||||
def deactivate
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
if defined?(Rack::MiniProfiler)
|
||||
Rack::MiniProfiler.config.tap do |config|
|
||||
config.position = "top-right"
|
||||
config.enable_hotwire_turbo_drive_support = true
|
||||
config.pre_authorize_cb = -> (_env) { File.exist?(Rails.root.join("tmp/rack-mini-profiler-dev.txt")) }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user