mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 07:49:29 +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
|
def set_collections
|
||||||
@collections = @account.collections
|
@collections = @account.collections
|
||||||
|
.with_tag
|
||||||
.with_item_count
|
.with_item_count
|
||||||
.order(created_at: :desc)
|
.order(created_at: :desc)
|
||||||
.offset(offset_param)
|
.offset(offset_param)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class Collection < ApplicationRecord
|
|||||||
.left_joins(:collection_items)
|
.left_joins(:collection_items)
|
||||||
.group(collections: :id)
|
.group(collections: :id)
|
||||||
}
|
}
|
||||||
|
scope :with_tag, -> { includes(:tag) }
|
||||||
|
|
||||||
def remote?
|
def remote?
|
||||||
!local?
|
!local?
|
||||||
|
|||||||
Reference in New Issue
Block a user