mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Fixed comment replies limiting (#15217)
The limit applies to the replies relation is applies globally when fetching a collection, which means only 3 replies in total will be fetched across all comments. This patches the findPage method to manually fetch the replies and replies adjacent relations manually on each comment, applying the limit on a comment-by-comment basis. This is not optimised as we currently still make the initial request for relations.
This commit is contained in:
parent
a0ce5b4b7e
commit
ae8cd7c0f4
1 changed files with 19 additions and 0 deletions
|
@ -201,6 +201,25 @@ const Comment = ghostBookshelf.Model.extend({
|
|||
return options;
|
||||
},
|
||||
|
||||
async findPage(options) {
|
||||
const {withRelated} = this.defaultRelations('findPage', options);
|
||||
|
||||
const relationsToLoadIndividually = [
|
||||
'replies',
|
||||
'replies.member',
|
||||
'replies.count.likes',
|
||||
'replies.count.liked'
|
||||
].filter(relation => withRelated.includes(relation));
|
||||
|
||||
const result = await ghostBookshelf.Model.findPage.call(this, options);
|
||||
|
||||
for (const model of result.data) {
|
||||
await model.load(relationsToLoadIndividually);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
countRelations() {
|
||||
return {
|
||||
replies(modelOrCollection) {
|
||||
|
|
Loading…
Add table
Reference in a new issue