Remove force summary mode for megatopics for now.

The logic is too hairy and we can't reliably determine
when to force summary mode. Work is underway to improve
perf for megatopics so this will not be required
eventually.
This commit is contained in:
Guo Xiang Tan 2018-06-26 11:05:25 +08:00
parent 67a986f30d
commit 0b6a2e9d1f
5 changed files with 4 additions and 60 deletions

View File

@ -177,14 +177,9 @@ export default function transformPost(
const postStream = topic.get("postStream");
postAtts.userFilters = postStream.userFilters;
if (topic.force_summary_mode) {
postStream.set("summary", topic.force_summary_mode);
}
postAtts.topicSummaryEnabled = postStream.summary;
postAtts.topicWordCount = topic.word_count;
postAtts.hasTopicSummary = topic.has_summary || topic.force_summary_mode;
postAtts.hasTopicSummary = topic.has_summary;
}
if (postAtts.isDeleted) {

View File

@ -67,8 +67,7 @@ class TopicViewSerializer < ApplicationSerializer
:message_bus_last_id,
:participant_count,
:destination_category_id,
:pm_with_non_human_user,
:force_summary_mode,
:pm_with_non_human_user
# TODO: Split off into proper object / serializer
def details
@ -300,10 +299,6 @@ class TopicViewSerializer < ApplicationSerializer
object.topic.shared_draft.present?
end
def force_summary_mode
object.force_summary_mode?
end
private
def private_message?(topic)

View File

@ -20,7 +20,6 @@ class WebHookTopicViewSerializer < TopicViewSerializer
topic_timer
private_topic_timer
details
force_summary_mode
}.each do |attr|
define_method("include_#{attr}?") do
false

View File

@ -406,13 +406,6 @@ class TopicView
end
end
def force_summary_mode?
@force_summary_mode ||=
@filter != 'none' &&
@topic.closed? &&
@topic.posts_count >= (MEGA_TOPIC_POSTS_COUNT * 2)
end
protected
def read_posts_set
@ -490,11 +483,9 @@ class TopicView
@filtered_posts = unfiltered_posts
# Filters
if @filter == 'summary' ||
((@_post_number.blank? || @_post_number.to_i == 1) && force_summary_mode?)
if @filter == 'summary'
@filtered_posts = @filtered_posts.summary(@topic.id)
@contains_gaps = true unless force_summary_mode?
@contains_gaps = true
end
if @best.present?

View File

@ -364,42 +364,6 @@ describe TopicView do
end
end
describe 'when a megalodon topic is closed' do
before do
@original_const = TopicView::MEGA_TOPIC_POSTS_COUNT
TopicView.send(:remove_const, "MEGA_TOPIC_POSTS_COUNT")
TopicView.const_set("MEGA_TOPIC_POSTS_COUNT", 1)
topic.update!(closed: true)
SiteSetting.summary_max_results = 2
end
after do
TopicView.send(:remove_const, "MEGA_TOPIC_POSTS_COUNT")
TopicView.const_set("MEGA_TOPIC_POSTS_COUNT", @original_const)
end
it 'should be forced into summary mode without gaps' do
topic_view = TopicView.new(topic.id, evil_trout, post_number: 1)
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p5])
end
it 'should not be forced into summary mode if post_number is not blank' do
topic_view = TopicView.new(topic.id, evil_trout, post_number: 2)
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p1, p2, p3])
end
it 'should not be forced into summary mode if filter is none' do
topic_view = TopicView.new(topic.id, evil_trout, filter: 'none')
expect(topic_view.contains_gaps?).to eq(false)
expect(topic_view.posts).to eq([p1, p2, p3])
end
end
it "#restricts to correct topic" do
t2 = Fabricate(:topic)