mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 10:38:14 +08:00
49f0cc16ba
This corrects two issues: 1. We were double serializing topic tracking state (as_json calls were not cached) 2. We were inefficiently serializing items by instantiating extra objects
36 lines
798 B
Ruby
36 lines
798 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TopicTrackingStateItemSerializer < ApplicationSerializer
|
|
attributes :topic_id,
|
|
:highest_post_number,
|
|
:last_read_post_number,
|
|
:created_at,
|
|
:category_id,
|
|
:is_category_topic,
|
|
:notification_level,
|
|
:created_in_new_period,
|
|
:treat_as_new_topic_start_date,
|
|
:tags
|
|
|
|
def created_in_new_period
|
|
return true if !scope
|
|
object.created_at >= treat_as_new_topic_start_date
|
|
end
|
|
|
|
def include_tags?
|
|
object.respond_to?(:tags)
|
|
end
|
|
|
|
def is_category_topic
|
|
object.topic_id == object.category_topic_id
|
|
end
|
|
|
|
def include_is_category_topic?
|
|
object.respond_to?(:category_topic_id)
|
|
end
|
|
|
|
def object=(value)
|
|
@object = value
|
|
end
|
|
end
|