mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 15:29:39 +08:00
913db5d546
Previously, for every bookmarked topic, all topic_user records were being preloaded. Only the current user's record is actually required. This commit introduces a new `perform_custom_preload!` API which bookmarkables can use to add custom preloading logic. We use this in topic_bookmarkable to load just the topic_user data we need (in the same way as `topic_list.rb`). Co-authored-by: Blake Erickson <o.blakeerickson@gmail.com>
61 lines
956 B
Ruby
61 lines
956 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative 'post_item_excerpt'
|
|
|
|
class UserPostTopicBookmarkBaseSerializer < UserBookmarkBaseSerializer
|
|
include TopicTagsMixin
|
|
include PostItemExcerpt
|
|
|
|
attributes :topic_id,
|
|
:linked_post_number,
|
|
:deleted,
|
|
:hidden,
|
|
:category_id,
|
|
:closed,
|
|
:archived,
|
|
:archetype,
|
|
:highest_post_number,
|
|
:bumped_at,
|
|
:slug
|
|
|
|
def topic_id
|
|
topic.id
|
|
end
|
|
|
|
def title
|
|
topic.title
|
|
end
|
|
|
|
def fancy_title
|
|
topic.fancy_title
|
|
end
|
|
|
|
def category_id
|
|
topic.category_id
|
|
end
|
|
|
|
def archetype
|
|
topic.archetype
|
|
end
|
|
|
|
def archived
|
|
topic.archived
|
|
end
|
|
|
|
def closed
|
|
topic.closed
|
|
end
|
|
|
|
def highest_post_number
|
|
scope.is_whisperer? ? topic.highest_staff_post_number : topic.highest_post_number
|
|
end
|
|
|
|
def bumped_at
|
|
topic.bumped_at
|
|
end
|
|
|
|
def slug
|
|
topic.slug
|
|
end
|
|
end
|