mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
PERF: move 3 more option columns out of the user table
This commit is contained in:
@ -70,6 +70,14 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
object.user_option.automatically_unpin_topics
|
||||
end
|
||||
|
||||
def should_be_redirected_to_top
|
||||
object.user_option.should_be_redirected_to_top
|
||||
end
|
||||
|
||||
def redirected_to_top
|
||||
object.user_option.redirected_to_top
|
||||
end
|
||||
|
||||
def site_flagged_posts_count
|
||||
PostAction.flagged_posts_count
|
||||
end
|
||||
@ -103,7 +111,7 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
end
|
||||
|
||||
def include_redirected_to_top?
|
||||
object.redirected_to_top.present?
|
||||
object.user_option.redirected_to_top.present?
|
||||
end
|
||||
|
||||
def custom_fields
|
||||
|
@ -45,7 +45,7 @@ class ListableTopicSerializer < BasicTopicSerializer
|
||||
def seen
|
||||
return true if !scope || !scope.user
|
||||
return true if object.user_data && !object.user_data.last_read_post_number.nil?
|
||||
return true if object.created_at < scope.user.treat_as_new_topic_start_date
|
||||
return true if object.created_at < scope.user.user_option.treat_as_new_topic_start_date
|
||||
false
|
||||
end
|
||||
|
||||
|
@ -11,10 +11,21 @@ class UserOptionSerializer < ApplicationSerializer
|
||||
:disable_jump_reply,
|
||||
:digest_after_days,
|
||||
:automatically_unpin_topics,
|
||||
:edit_history_public
|
||||
:edit_history_public,
|
||||
:auto_track_topics_after_msecs,
|
||||
:new_topic_duration_minutes
|
||||
|
||||
|
||||
def include_edit_history_public?
|
||||
!SiteSetting.edit_history_visible_to_public
|
||||
end
|
||||
|
||||
def auto_track_topics_after_msecs
|
||||
object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs
|
||||
end
|
||||
|
||||
def new_topic_duration_minutes
|
||||
object.new_topic_duration_minutes || SiteSetting.default_other_new_topic_duration_minutes
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -82,8 +82,6 @@ class UserSerializer < BasicUserSerializer
|
||||
:can_delete_all_posts
|
||||
|
||||
private_attributes :locale,
|
||||
:auto_track_topics_after_msecs,
|
||||
:new_topic_duration_minutes,
|
||||
:muted_category_ids,
|
||||
:tracked_category_ids,
|
||||
:watched_category_ids,
|
||||
@ -253,14 +251,6 @@ class UserSerializer < BasicUserSerializer
|
||||
### PRIVATE ATTRIBUTES
|
||||
###
|
||||
|
||||
def auto_track_topics_after_msecs
|
||||
object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs
|
||||
end
|
||||
|
||||
def new_topic_duration_minutes
|
||||
object.new_topic_duration_minutes || SiteSetting.default_other_new_topic_duration_minutes
|
||||
end
|
||||
|
||||
def muted_category_ids
|
||||
CategoryUser.lookup(object, :muted).pluck(:category_id)
|
||||
end
|
||||
|
Reference in New Issue
Block a user