mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
PERF: Make mega topics work without a stream.
There are tradeoffs that we took here. For the complete story see https://meta.discourse.org/t/performance-improvements-on-long-topics/30187/27?u=tgxworld.
This commit is contained in:
@ -347,10 +347,28 @@ export default function() {
|
||||
|
||||
this.get("/t/:topic_id/posts.json", request => {
|
||||
const postIds = request.queryParams.post_ids;
|
||||
const posts = postIds.map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
}));
|
||||
const postNumber = parseInt(request.queryParams.post_number);
|
||||
let posts;
|
||||
|
||||
if (postIds) {
|
||||
posts = postIds.map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "true") {
|
||||
posts = _.range(postNumber + 1, postNumber + 6).map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "false") {
|
||||
posts = _.range(postNumber - 5, postNumber)
|
||||
.reverse()
|
||||
.map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
}));
|
||||
}
|
||||
|
||||
return response(200, { post_stream: { posts } });
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user