PERF: Don't display days ago on timeline for megatopics.

Analysis using `pg_stat_statements` showed this query
to be eating up a significant portion of CPU.
This commit is contained in:
Guo Xiang Tan
2018-06-20 16:24:09 +08:00
parent cbdab71179
commit 9c925a66ff
3 changed files with 49 additions and 5 deletions

View File

@@ -549,4 +549,30 @@ describe TopicView do
end
end
end
describe '#filtered_post_stream' do
let!(:post) { Fabricate(:post, topic: topic, user: first_poster) }
let!(:post2) { Fabricate(:post, topic: topic, user: evil_trout) }
let!(:post3) { Fabricate(:post, topic: topic, user: first_poster) }
it 'should return the right columns' do
expect(topic_view.filtered_post_stream).to eq([
[post.id, post.post_number, 0],
[post2.id, post2.post_number, 0],
[post3.id, post3.post_number, 0]
])
end
describe 'for mega topics' do
it 'should return the right columns' do
SiteSetting.auto_close_topics_post_count = 2
expect(topic_view.filtered_post_stream).to eq([
[post.id, post.post_number],
[post2.id, post2.post_number],
[post3.id, post3.post_number]
])
end
end
end
end