mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Preload tag to prevent n+1 (#37154)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -44,6 +44,7 @@ class Collection < ApplicationRecord
|
||||
.left_joins(:collection_items)
|
||||
.group(collections: :id)
|
||||
}
|
||||
scope :with_tag, -> { includes(:tag) }
|
||||
|
||||
def remote?
|
||||
!local?
|
||||
|
||||
Reference in New Issue
Block a user