mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 18:13:39 +08:00
PERF: Do not calculate gaps for TopicViewPostsSerializer
.
The client doesn't use the gaps results when loading new posts.
This commit is contained in:
parent
3ddfc12307
commit
969e79d7c6
|
@ -12,10 +12,18 @@ module PostStreamSerializerMixin
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def include_gaps?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def post_stream
|
def post_stream
|
||||||
result = { posts: posts }
|
result = { posts: posts }
|
||||||
result[:stream] = object.filtered_post_ids if include_stream?
|
result[:stream] = object.filtered_post_ids if include_stream?
|
||||||
result[:gaps] = GapSerializer.new(object.gaps, root: false) if object.gaps.present?
|
|
||||||
|
if include_gaps? && object.gaps.present?
|
||||||
|
result[:gaps] = GapSerializer.new(object.gaps, root: false)
|
||||||
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@ class TopicViewPostsSerializer < ApplicationSerializer
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def include_gaps?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def include_timeline_lookup?
|
def include_timeline_lookup?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,5 +22,6 @@ RSpec.describe TopicViewPostsSerializer do
|
||||||
expect(posts.first["id"]).to eq(post.id)
|
expect(posts.first["id"]).to eq(post.id)
|
||||||
expect(body["post_stream"]["stream"]).to eq(nil)
|
expect(body["post_stream"]["stream"]).to eq(nil)
|
||||||
expect(body["post_stream"]["timeline_lookup"]).to eq(nil)
|
expect(body["post_stream"]["timeline_lookup"]).to eq(nil)
|
||||||
|
expect(body["post_stream"]["gaps"]).to eq(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user