mirror of
https://github.com/TryGhost/Ghost.git
synced 2023-12-13 21:00:40 +01:00
Merge pull request #5817 from ErisDS/issue-5810-sqlite
Don't eager load relations on tag update
This commit is contained in:
commit
c57edd67a7
1 changed files with 26 additions and 17 deletions
|
@ -283,10 +283,17 @@ to004 = function to004() {
|
|||
|
||||
// Add post_tag order
|
||||
upgradeOp = function () {
|
||||
return models.Post.findAll(_.extend({}, options, {withRelated: ['tags']})).then(function (posts) {
|
||||
var tagOps = [];
|
||||
logInfo('Collecting data on tag order for posts...');
|
||||
return models.Post.findAll(_.extend({}, options)).then(function (posts) {
|
||||
if (posts) {
|
||||
posts.each(function (post) {
|
||||
return posts.mapThen(function (post) {
|
||||
return post.load(['tags']);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}).then(function (posts) {
|
||||
_.each(posts, function (post) {
|
||||
var order = 0;
|
||||
post.related('tags').each(function (tag) {
|
||||
tagOps.push((function (order) {
|
||||
|
@ -300,10 +307,12 @@ to004 = function to004() {
|
|||
order += 1;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (tagOps.length > 0) {
|
||||
logInfo('Updating order on ' + tagOps.length + ' tags');
|
||||
return sequence(tagOps);
|
||||
logInfo('Updating order on ' + tagOps.length + ' tag relationships (could take a while)...');
|
||||
return sequence(tagOps).then(function () {
|
||||
logInfo('Tag order successfully updated');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue