Preload tag to prevent n+1 (#37154)

This commit is contained in:
David Roetzel
2025-12-08 11:30:10 +01:00
committed by GitHub
parent 8625721805
commit 55becaa1b5
2 changed files with 2 additions and 0 deletions

View File

@@ -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)

View File

@@ -44,6 +44,7 @@ class Collection < ApplicationRecord
.left_joins(:collection_items)
.group(collections: :id)
}
scope :with_tag, -> { includes(:tag) }
def remote?
!local?