Revert "PERF: Don't join on shared drafts unless you have to"

This reverts commit efedd9745fd9c34ac982941cca79f8ab8e517328.
This commit is contained in:
Robin Ward
2018-03-28 15:35:13 -04:00
parent a8f211bd41
commit 4b5977aa6a
5 changed files with 22 additions and 47 deletions

View File

@ -9,26 +9,12 @@ class TopicListSerializer < ApplicationSerializer
:per_page,
:top_tags,
:tags,
:shared_drafts,
:topics
:shared_drafts
has_many :topics, serializer: TopicListItemSerializer, embed: :objects
has_many :shared_drafts, serializer: TopicListItemSerializer, embed: :objects
has_many :tags, serializer: TagSerializer, embed: :objects
def topics
object.topics.map do |t|
serializer = TopicListItemSerializer.new(t, scope: scope, root: false)
if scope.can_create_shared_draft? &&
object.category&.id == SiteSetting.shared_drafts_category.to_i
serializer.include_destination_category = true
end
serializer
end
end
def can_create_topic
scope.can_create?(Topic)
end