mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:21:23 +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:
@ -484,6 +484,54 @@ QUnit.test("loadIntoIdentityMap with post ids", assert => {
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("appendMore for megatopic", assert => {
|
||||
const postStream = buildStream(1234);
|
||||
const store = createStore();
|
||||
const post = store.createRecord("post", { id: 1, post_number: 1 });
|
||||
|
||||
postStream.setProperties({
|
||||
isMegaTopic: true,
|
||||
posts: [post]
|
||||
});
|
||||
|
||||
return postStream.appendMore().then(() => {
|
||||
assert.present(
|
||||
postStream.findLoadedPost(2),
|
||||
"it adds the returned post to the store"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
postStream.get("posts").length,
|
||||
6,
|
||||
"it adds the right posts into the stream"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("prependMore for megatopic", assert => {
|
||||
const postStream = buildStream(1234);
|
||||
const store = createStore();
|
||||
const post = store.createRecord("post", { id: 6, post_number: 6 });
|
||||
|
||||
postStream.setProperties({
|
||||
isMegaTopic: true,
|
||||
posts: [post]
|
||||
});
|
||||
|
||||
return postStream.prependMore().then(() => {
|
||||
assert.present(
|
||||
postStream.findLoadedPost(5),
|
||||
"it adds the returned post to the store"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
postStream.get("posts").length,
|
||||
6,
|
||||
"it adds the right posts into the stream"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("staging and undoing a new post", assert => {
|
||||
const postStream = buildStream(10101, [1]);
|
||||
const store = postStream.store;
|
||||
@ -801,3 +849,53 @@ QUnit.test("postsWithPlaceholders", assert => {
|
||||
assert.equal(testProxy.objectAt(3), p4);
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("filteredPostsCount", assert => {
|
||||
const postStream = buildStream(4567, [1, 3, 4]);
|
||||
|
||||
assert.equal(postStream.get("filteredPostsCount"), 3);
|
||||
|
||||
// Megatopic
|
||||
postStream.set("isMegaTopic", true);
|
||||
postStream.set("topic.highest_post_number", 4);
|
||||
|
||||
assert.equal(postStream.get("filteredPostsCount"), 4);
|
||||
});
|
||||
|
||||
QUnit.test("firstPostId", assert => {
|
||||
const postStream = buildStream(4567, [1, 3, 4]);
|
||||
|
||||
assert.equal(postStream.get("firstPostId"), 1);
|
||||
|
||||
postStream.setProperties({
|
||||
isMegaTopic: true,
|
||||
firstId: 2
|
||||
});
|
||||
|
||||
assert.equal(postStream.get("firstPostId"), 2);
|
||||
});
|
||||
|
||||
QUnit.test("lastPostId", assert => {
|
||||
const postStream = buildStream(4567, [1, 3, 4]);
|
||||
|
||||
assert.equal(postStream.get("lastPostId"), 4);
|
||||
|
||||
postStream.setProperties({
|
||||
isMegaTopic: true,
|
||||
lastId: 2
|
||||
});
|
||||
|
||||
assert.equal(postStream.get("lastPostId"), 2);
|
||||
});
|
||||
|
||||
QUnit.test("progressIndexOfPostId", assert => {
|
||||
const postStream = buildStream(4567, [1, 3, 4]);
|
||||
const store = createStore();
|
||||
const post = store.createRecord("post", { id: 1, post_number: 5 });
|
||||
|
||||
assert.equal(postStream.progressIndexOfPostId(post), 1);
|
||||
|
||||
postStream.set("isMegaTopic", true);
|
||||
|
||||
assert.equal(postStream.progressIndexOfPostId(post), 5);
|
||||
});
|
||||
|
Reference in New Issue
Block a user