mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-23 16:44:04 -05:00
Fix n+1 query for bookmarks on statuses (#12494)
This commit is contained in:
parent
d9793b2367
commit
07da35c17c
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class StatusRelationshipsPresenter
|
class StatusRelationshipsPresenter
|
||||||
attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map
|
attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map,
|
||||||
|
:bookmarks_map
|
||||||
|
|
||||||
def initialize(statuses, current_account_id = nil, **options)
|
def initialize(statuses, current_account_id = nil, **options)
|
||||||
if current_account_id.nil?
|
if current_account_id.nil?
|
||||||
|
@ -95,8 +95,8 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bookmarked
|
def bookmarked
|
||||||
if instance_options && instance_options[:bookmarks]
|
if instance_options && instance_options[:relationships]
|
||||||
instance_options[:bookmarks].bookmarks_map[object.id] || false
|
instance_options[:relationships].bookmarks_map[object.id] || false
|
||||||
else
|
else
|
||||||
current_user.account.bookmarked?(object)
|
current_user.account.bookmarked?(object)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user