Preload tag to prevent n+1 (#37154)

This commit is contained in:
David Roetzel authored and GitHub committed 2025-12-08 10:30:10 +00:00
1 parent 8625721805
commit 55becaa1b5
2 files changed
+2

No files matched your search

@@ -70,6 +70,7 @@ class Api::V1Alpha::CollectionsController < Api::BaseController
def set_collections
@collections = @account.collections
.with_tag
.with_item_count
.order(created_at: :desc)
.offset(offset_param)
+1
View File
@@ -44,6 +44,7 @@ class Collection < ApplicationRecord
.left_joins(:collection_items)
.group(collections: :id)
}
scope :with_tag, -> { includes(:tag) }
def remote?
!local?